AJH.CMS.WEB.UI.Admin.ManageGallery_UC.btnAdd_Click C# (CSharp) Method

btnAdd_Click() private method

private btnAdd_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        void btnAdd_Click(object sender, EventArgs e)
        {
            if (ViewState[CMSViewStateManager.CategoryID] != null)
            {
                try
                {
                    CMS.Core.Entities.Gallery gallery = new Core.Entities.Gallery();
                    gallery.CategoryID = Convert.ToInt32(ViewState[CMSViewStateManager.CategoryID]);
                    gallery.ID = 0;
                    gallery.IsDeleted = false;
                    gallery.LanguageID = CMSContext.LanguageID;
                    gallery.GalleryItemType = (CMSEnums.GalleryItemType)Convert.ToInt32(cddGalleryItemType.SelectedValue);
                    gallery.GalleryType = CMSEnums.GalleryType.Photo;
                    gallery.Name = txtAddName.Text;
                    gallery.Order = 0;
                    gallery.PortalID = CMSContext.PortalID;
                    gallery.URL = txtAddURL.Text;
                    gallery.CreatedBy = CMSContext.CurrentUserID;
                    switch (gallery.GalleryItemType)
                    {
                        case CMSEnums.GalleryItemType.Internal:
                            List<string> FilesUpload = ucSWFUpload.GetFilesName();
                            if (FilesUpload != null && FilesUpload.Count > 0)
                            {
                                for (int i = 0; i < FilesUpload.Count; i++)
                                {
                                    gallery.Name = Path.GetFileNameWithoutExtension(FilesUpload[i]);
                                    gallery.File = FilesUpload[i];
                                    GalleryManager.Add(gallery);
                                }

                            }
                            break;
                        case CMSEnums.GalleryItemType.External:
                            GalleryManager.Add(gallery);
                            break;
                    }

                    BeginAddMode();
                    FillGallerys();
                    upnlGallery.Update();
                }
                catch (Exception ex)
                {
                    dvProblems.Visible = true;
                    dvProblems.InnerText = ex.ToString();
                    upnlGallery.Update();
                }
            }
        }
        #endregion