Example #1
0
 public async Task<ActionResult> Gallery(Models.Gallery _gallery)
 {
   ViewBag.Message = "Gallery";
   if(_gallery==null)
   {
     _gallery = new Models.Gallery();
   }
   if(_gallery.SearchCategories==null)
   {
     _gallery.SearchCategories = Mapper.Map<IList<IcedMemories.Domain.Models.SearchCategory>, IList<Models.SearchCategorySelection>>(await WorkManager.SearchCategoryManager.GetCategoriesAsync());
     foreach (Models.SearchCategorySelection _category in _gallery.SearchCategories)
     {
       _category.Options = Mapper.Map<IList<IcedMemories.Domain.Models.SearchCategoryOption>, IList<Models.SearchCategoryOptionSelection>>(await WorkManager.SearchCategoryOptionManager.GetCategoryOptionsAsync(_category.Id));
     }
   }
   System.Collections.Generic.List<IcedMemories.Domain.Models.SearchCategoryOption> _searchCategoryOptions = new List<IcedMemories.Domain.Models.SearchCategoryOption>();
   IcedMemories.Domain.Models.SearchCategoryOption _searchOption;
   foreach(Models.SearchCategorySelection _selectedCategory in _gallery.SearchCategories)
   {
     foreach(Models.SearchCategoryOptionSelection _selectedOption in _selectedCategory.Options)
     {
       if(_selectedOption.Selected == true)
       {
         _searchOption = new Domain.Models.SearchCategoryOption();
         _searchOption.Id = _selectedOption.Id;
         _searchOption.CategoryId = _selectedCategory.Id;
         _searchOption.Name = _selectedOption.Name;
         _searchCategoryOptions.Add(_searchOption);
       }
     }
   }
   _gallery.Cakes = Mapper.Map<IList<IcedMemories.Domain.Models.Cake>, IList<Models.CakeViewModel>>(await WorkManager.CakeManager.GetCakesAsync(_searchCategoryOptions));
   return View(_gallery);
 }
Example #2
0
 public async Task <ActionResult> Gallery(Models.Gallery _gallery)
 {
     ViewBag.Message = "Gallery";
     if (_gallery == null)
     {
         _gallery = new Models.Gallery();
     }
     if (_gallery.SearchCategories == null)
     {
         _gallery.SearchCategories = Mapper.Map <IList <IcedMemories.Domain.Models.SearchCategory>, IList <Models.SearchCategorySelection> >(await WorkManager.SearchCategoryManager.GetCategoriesAsync());
         foreach (Models.SearchCategorySelection _category in _gallery.SearchCategories)
         {
             _category.Options = Mapper.Map <IList <IcedMemories.Domain.Models.SearchCategoryOption>, IList <Models.SearchCategoryOptionSelection> >(await WorkManager.SearchCategoryOptionManager.GetCategoryOptionsAsync(_category.Id));
         }
     }
     System.Collections.Generic.List <IcedMemories.Domain.Models.SearchCategoryOption> _searchCategoryOptions = new List <IcedMemories.Domain.Models.SearchCategoryOption>();
     IcedMemories.Domain.Models.SearchCategoryOption _searchOption;
     foreach (Models.SearchCategorySelection _selectedCategory in _gallery.SearchCategories)
     {
         foreach (Models.SearchCategoryOptionSelection _selectedOption in _selectedCategory.Options)
         {
             if (_selectedOption.Selected == true)
             {
                 _searchOption            = new Domain.Models.SearchCategoryOption();
                 _searchOption.Id         = _selectedOption.Id;
                 _searchOption.CategoryId = _selectedCategory.Id;
                 _searchOption.Name       = _selectedOption.Name;
                 _searchCategoryOptions.Add(_searchOption);
             }
         }
     }
     _gallery.Cakes = Mapper.Map <IList <IcedMemories.Domain.Models.Cake>, IList <Models.CakeViewModel> >(await WorkManager.CakeManager.GetCakesAsync(_searchCategoryOptions));
     return(View(_gallery));
 }
        public ActionResult AddGallery(HttpPostedFileBase[] Images, Int64 GalleryID = 0, string Title = null)
        {
            string userid = User.Identity.GetUserId();
            string Status = "";

            Models.Gallery gal = new Models.Gallery();

            var exsist = db.Gallery.Where(s => s.GalleryID == GalleryID).FirstOrDefault();

            if (exsist == null)
            {
                for (int i = 0; i < Images.Length; i++)
                {
                    string path = Server.MapPath("~/UploadedImage/");
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }

                    Images[i].SaveAs(path + Path.GetFileName(Images[i].FileName));

                    gal.Title     = Title;
                    gal.Images    = Images[i].FileName;
                    gal.CreatedBy = userid;
                    gal.CreatedOn = DateTime.Now;
                    db.Gallery.Add(gal);
                    db.SaveChanges();
                }
            }



            return(RedirectToAction("AllImages", "Admin", new { area = "Admin" }));
        }
        public override System.Web.Mvc.ActionResult Edit(Models.Gallery gallery)
        {
            var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Edit);

            ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "gallery", gallery);
            EditOverride(callInfo, gallery);
            return(callInfo);
        }
        protected async Task Hide(Models.Gallery item)
        {
            await _galleryService.HideAsync(item.Id);

            await SaveAsync();

            StateHasChanged();
        }
        protected void Add()
        {
            Model        = new Models.Gallery();
            Model.Images = new List <Image>();

            _showAdd            = true;
            _isButtonAddVisible = false;
        }
Example #7
0
        public IActionResult EditGallery(Models.Gallery gallery)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            _writeModel.Save(gallery.MapToEntity(), new CancellationToken());
            return(RedirectToAction("Index").WithSuccess("Gallery saved"));;
        }
Example #8
0
        public int Insert(Models.Gallery gallery)
        {
            tblGallery newGallery = new tblGallery {
                GalleryName = gallery.GalleryName, GalleryDescription = gallery.GalleryDescription, UserId = gallery.UserId, DateCreated = gallery.DateCreated
            };

            db.Galleries.Add(newGallery);

            db.SaveChanges();
            return(newGallery.Id);
        }
Example #9
0
        public void Update(Models.Gallery gallery)
        {
            var existing = db.Galleries.SingleOrDefault(x => x.Id == gallery.Id);

            if (existing != null)
            {
                existing.GalleryName        = gallery.GalleryName;
                existing.GalleryDescription = gallery.GalleryDescription;
                existing.DateCreated        = gallery.DateCreated;
                db.SaveChanges();
            }
        }
Example #10
0
        public void DeleteTest()
        {
            Gallery gallery = new Gallery();
            List <Models.Gallery> gallerys = new List <Models.Gallery>();

            gallerys = gallery.Load();
            Models.Gallery row = gallerys.Where(x => x.Id == 2).FirstOrDefault();
            if (row != null)
            {
                bool actual = gallery.Delete(row.Id);
                Assert.IsTrue(actual == true);
            }
        }
        public GalleryAddOrUpdateResponseDto AddOrUpdate(GalleryAddOrUpdateRequestDto request)
        {
            var entity = _repository.GetAll()
                         .FirstOrDefault(x => x.Id == request.Id && x.IsDeleted == false);

            if (entity == null)
            {
                _repository.Add(entity = new Models.Gallery());
            }
            entity.Name = request.Name;
            _uow.SaveChanges();
            return(new GalleryAddOrUpdateResponseDto(entity));
        }
Example #12
0
        public virtual System.Web.Mvc.ActionResult DeleteConfirmed(System.Guid id)
        {
            Models.Gallery oGallery =
                UnitOfWork.GalleryRepository.Get()
                .Where(current => current.Id == id)
                .FirstOrDefault()
            ;

            UnitOfWork.GalleryRepository.Delete(oGallery);

            UnitOfWork.Save();

            return(RedirectToAction(MVC.Gallery.AdminIndex()));
        }
        public ActionResult Delete(int Id)
        {
            Models.Gallery foundGallery = db.Gallery.FirstOrDefault(g => g.Id == Id);

            if (foundGallery != null)
            {
                db.Gallery.Remove(foundGallery);
                db.SaveChanges();
            }
            else
            {
                return(HttpNotFound());
            }
            return(RedirectToAction("Index"));
        }
Example #14
0
        public virtual System.Web.Mvc.ActionResult Details(System.Guid id)
        {
            Models.Gallery oGallery =
                UnitOfWork.GalleryRepository.Get()
                .Where(current => current.Id == id)
                .FirstOrDefault()
            ;

            if (oGallery == null)
            {
                return(HttpNotFound());
            }

            return(View(oGallery));
        }
Example #15
0
        public virtual System.Web.Mvc.ActionResult Create(Models.Gallery gallery)
        {
            if (ModelState.IsValid)
            {
                if (Request.Files["FileName"].ContentLength > 0)
                {
                    string   directoryReal = "";
                    string   type          = Request.Files["FileName"].ContentType;
                    string[] type2         = type.Split('/');
                    string   fileType      = string.Format("{0}{1}", ".", type2[1]);
                    if (fileType == ".mp4" || fileType == ".kmv")
                    {
                        directoryReal = string.Format("{0}/{1}", Server.MapPath("~/Content/VideosFiles"), Request.Files["FileName"].FileName);
                        gallery.Type  = fileType;
                        string filname = Request.Files["FileName"].FileName;
                        Request.Files["FileName"].SaveAs(directoryReal);
                        gallery.FileName = filname;

                        UnitOfWork.GalleryRepository.Insert(gallery);

                        UnitOfWork.Save();

                        return(RedirectToAction(MVC.Gallery.AdminIndex()));
                    }
                    else if (fileType == ".jpg" || fileType == ".png" || fileType == ".gif" || fileType == ".jpeg")
                    {
                        directoryReal = string.Format("{0}/{1}", Server.MapPath("~/Content/GalleryFiles"), Request.Files["FileName"].FileName);
                        gallery.Type  = fileType;
                        string filname = Request.Files["FileName"].FileName;
                        Request.Files["FileName"].SaveAs(directoryReal);
                        gallery.FileName = filname;

                        UnitOfWork.GalleryRepository.Insert(gallery);

                        UnitOfWork.Save();

                        return(RedirectToAction(MVC.Gallery.AdminIndex()));
                    }
                    else
                    {
                        ViewBag.Message = Models.Resources.Messages.ErrorMessage;
                        gallery.Type    = fileType;
                    }
                }
            }

            return(View(gallery));
        }
Example #16
0
        public void UpdateTest()
        {
            Gallery gallery = new Gallery();
            List <Models.Gallery> gallerys = new List <Models.Gallery>();

            gallerys = gallery.Load();
            Models.Gallery row = gallerys.Where(m => m.Id == 1).FirstOrDefault();

            row.GalleryName = "UPDATED: Test Gallery.";
            gallery.Update(row);

            List <Models.Gallery> updated = new List <Models.Gallery>();

            updated = gallery.Load();
            Models.Gallery updatedGallery = updated.Where(x => x.Id == 1).FirstOrDefault();

            Assert.AreNotEqual(updatedGallery, row);
        }
Example #17
0
        //
        // GET: /Gallery/
        public ActionResult Index()
        {
            List<Models.Photo> photos = new List<Models.Photo>();

            var files = from f in System.IO.Directory.GetFiles(Server.MapPath(Url.Content("~/Content/images")))
                        where System.IO.Path.GetFileName(f).ToUpper().StartsWith("POUR")
                        select f;
            foreach (string fileName in files)
            {
                photos.Add(new Models.Photo { FileName = System.IO.Path.GetFileName(fileName), Title = GetTitle(fileName), SortKey = 1 });
            }

            //photos.Sort((p1, p2) => { return p1.SortKey.CompareTo(p2.SortKey); });

            Models.Gallery gallery = new Models.Gallery { Name = "Gallery", Photos = photos };

            return View(gallery);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     presenters = new GalleryPresenter
     {
         repository = new MemoryRepository()
     };
     if (IsPostBack)
     {
         int count = FileUpload1.PostedFiles.Count;
         Models.Gallery[] galleries = new Models.Gallery[count];
         for (int i = 0; i < count; ++i)
         {
             int    number   = presenters.Count() + i;
             string fileName = "~/Images/Galleries/" + number + ".jpeg";
             FileUpload1.PostedFiles[i].SaveAs(Server.MapPath(fileName));
             galleries[i]       = new Models.Gallery();
             galleries[i].image = Server.MapPath(fileName);
         }
         Response.Redirect(((RedirectResult)presenters.GetResult(galleries)).Url);
     }
 }
Example #19
0
        public Models.Gallery LoadById(int id)
        {
            var gallery = db.Galleries.FirstOrDefault(a => a.Id == id);

            if (gallery != null)
            {
                Models.Gallery a = new Models.Gallery
                {
                    Id                 = gallery.Id,
                    UserId             = gallery.UserId.GetValueOrDefault(),
                    GalleryName        = gallery.GalleryName,
                    GalleryDescription = gallery.GalleryDescription,
                    DateCreated        = gallery.DateCreated
                };
                return(a);
            }
            else
            {
                throw new Exception("Row was not found.");
            }
        }
Example #20
0
        public Boolean AddGallery(Models.Gallery Model)
        {
            Boolean Status = ExecutionGeneral(String.Format("insert into [dbo].[GallarySet] ([Ga_Title],[Ga_Description],[Ga_Showable]) values('{0}','{1}',1)", Model.Ga_Title, Model.Ga_Title));

            if (Status)
            {
                DataSet myrec = GeneralData("select max(Ga_Id) Ga_Id into from [dbo].[GallarySet]");
                if (myrec.Tables[0].Rows.Count > 0)
                {
                    int Ga_Id = Int32.Parse(myrec.Tables[0].Rows[0]["Ga_Id"].ToString());
                    foreach (Models.Photo Photo in Model.Photoes)
                    {
                        Status = ExecutionGeneral(String.Format("insert into [dbo].[PhotoSet] ([Ph_Description],[Ph_Title],[Ph_Path],[Gallary_Ga_Id],[Ph_Showable]) values('{0}','{1}','{2}',{3},1)", Photo.Ph_Description, Photo.Ph_Title, Photo.Ph_Path, Ga_Id));
                        if (!Status)
                        {
                            return(Status);
                        }
                    }
                }
            }
            return(Status);
        }
        protected void ExpandGallery(Models.Gallery gallery)
        {
            gallery.Class = gallery.Class == "gallery-expanded" ? "" : "gallery-expanded";

            // isGalleryExpanded = !isGalleryExpanded;
        }
 protected void Edit(Models.Gallery item)
 {
     _showAdd            = true;
     _isButtonAddVisible = false;
     Model = item;
 }
 partial void EditOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Models.Gallery gallery);
Example #24
0
 public List <gallery> GetGalleryType()
 {
     Models.Gallery g = new Models.Gallery(this.db);
     return(g.List());
 }
Example #25
0
 public GalleryAddOrUpdateResponseDto(Models.Gallery entity)
     : base(entity)
 {
 }
Example #26
0
 public GalleryDto(Models.Gallery entity)
 {
     Id   = entity.Id;
     Name = entity.Name;
 }