// GET: Admin/Fav public ActionResult UpdateFav() { FavDTO dto = new FavDTO(); dto = bll.GetFav(); return(View(dto)); }
// GET: Admin/Fav public ActionResult UpdateFav() { FavDTO model = new FavDTO(); model = bll.GetFav(); return(View(model)); }
public FavDTO UpdateFav(FavDTO model) { try { FavLogoTitle fav = db.FavLogoTitles.First(); FavDTO dto = new FavDTO(); dto.ID = model.ID; dto.Fav = fav.Fav; dto.Logo = fav.Logo; // Update Fav in DB. fav.Title = model.Title; if (model.Fav != null) { fav.Fav = model.Fav; } if (model.Logo != null) { fav.Logo = model.Logo; } db.SaveChanges(); return(dto); } catch (Exception ex) { throw ex; } }
public HomeLayoutDTO GetLayoutData() { HomeLayoutDTO dto = new HomeLayoutDTO(); dto.Categories = categoryDAO.GetCategoryList(); List <SocialMediaDTO> socialList = new List <SocialMediaDTO>(); socialList = socialDAO.GetSocialMediaData(); dto.Facebook = socialList.First(x => x.Link.Contains("facebook")); dto.Twitter = socialList.First(x => x.Link.Contains("twitter")); dto.Instagram = socialList.First(x => x.Link.Contains("instagram")); dto.YouTube = socialList.First(x => x.Link.Contains("youtube")); dto.LinkedIn = socialList.First(x => x.Link.Contains("linkedin")); FavDTO favDTO = new FavDTO(); dto.Fav = favDAO.GetFav(); List <MetaDTO> metaList = new List <MetaDTO>(); dto.MetaList = metaDAO.GetMetaData(); List <AddressDTO> addressList = addressDAO.GetAddresses(); dto.Address = addressList.First(); dto.hotNews = postDAO.GetHotNews(); return(dto); }
public FavDTO UpdateUser(FavDTO model) { try { FavLogoTitle fav = db.FavLogoTitles.First(); FavDTO dto = new FavDTO(); dto.ID = fav.ID; fav.Title = model.Title; dto.Fav = fav.Fav; dto.Logo = fav.Logo; if (model.Fav != null) { fav.Fav = model.Fav; } if (model.Logo != null) { fav.Logo = model.Logo; } fav.LastUpdateDate = DateTime.Now; fav.LastUpdateUserID = UserStatic.UserID; db.SaveChanges(); return(dto); } catch (Exception ex) { throw ex; } }
public async Task<IActionResult> AddFavItem([FromBody]FavDTO model) { try { await this.m_favoriteItemService.AddFavoriteAsync(model.UserId, model.ItemId); return this.Ok(); } catch(Exception exception) { return this.BadRequest(exception.Message); } }
public FavDTO UpdateFav(FavDTO model) { FavDTO dto = new FavDTO(); dto = dao.UpdateUser(model); LogDAO.AddLog(General.ProcessType.IconUpdated, General.TableName.Icon, dto.ID); return(dto); }
public FavDTO GetFav() { FavLogoTitle fav = db.FavLogoTitles.First(); FavDTO dto = new FavDTO(); dto.ID = fav.ID; dto.Title = fav.Title; dto.Logo = fav.Logo; dto.Fav = fav.Fav; return(dto); }
public ActionResult UpdateFav(FavDTO model) { if (!ModelState.IsValid) { ViewBag.ProcessState = General.Messages.EmptyArea; } else { if (model.FavImage != null) { HttpPostedFileBase postedFileFav = model.FavImage; string ext = Path.GetExtension(postedFileFav.FileName); if (ext == ".ico" || ext == ".png" || ext == ".jpg" || ext == "jpg") { Bitmap favImage = new Bitmap(postedFileFav.InputStream); Bitmap resizedFavImage = new Bitmap(favImage, 100, 100); string uniqueNumber = Guid.NewGuid().ToString(); string favName = uniqueNumber + postedFileFav.FileName; resizedFavImage.Save(Server.MapPath("~/Areas/Admin/Content/FavImages/" + favName)); model.Fav = favName; } else { ViewBag.ProcessState = General.Messages.ExtensionError; } } if (model.LogoImage != null) { HttpPostedFileBase postedFileLogo = model.LogoImage; string ext = Path.GetExtension(postedFileLogo.FileName); if (ext == ".ico" || ext == ".png" || ext == ".jpg" || ext == "jpg") { Bitmap logoImage = new Bitmap(postedFileLogo.InputStream); Bitmap resizedLogoImage = new Bitmap(logoImage, 500, 500); string uniqueNumber = Guid.NewGuid().ToString(); string logoName = uniqueNumber + postedFileLogo.FileName; resizedLogoImage.Save(Server.MapPath("~/Areas/Admin/Content/FavImages/" + logoName)); model.Logo = logoName; } else { ViewBag.ProcessState = General.Messages.ExtensionError; } } FavDTO returnDTO = new FavDTO(); returnDTO = bll.UpdateFav(model); if (model.FavImage != null) { string favImageFullPath = Server.MapPath("~/Areas/Admin/Content/FavImages/" + returnDTO.Fav); if (System.IO.File.Exists(favImageFullPath)) { System.IO.File.Delete(favImageFullPath); } } if (model.LogoImage != null) { string logoImageFullPath = Server.MapPath("~/Areas/Admin/Content/FavImages/" + returnDTO.Logo); if (System.IO.File.Exists(logoImageFullPath)) { System.IO.File.Delete(logoImageFullPath); } } ViewBag.ProcessState = General.Messages.UpdateSuccess; } return(View(model)); }
public ActionResult UpdateFav(FavDTO model) { if (!ModelState.IsValid) { ViewBag.ProcessState = General.Messages.EmptyArea; } else { if (model.FavImage != null) { HttpPostedFileBase postedFileFav = model.FavImage; string ext = Path.GetExtension(postedFileFav.FileName); string fileNameFav = string.Empty; if (ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".gif") { Bitmap favImage = new Bitmap(postedFileFav.InputStream); Bitmap resizedImageFav = new Bitmap(favImage, 100, 100); string uniqueNumberFav = Guid.NewGuid().ToString(); fileNameFav = uniqueNumberFav + postedFileFav.FileName; resizedImageFav.Save(Server.MapPath("~/Areas/Admin/Content/favimage/" + fileNameFav)); model.Fav = fileNameFav; } else { ViewBag.ProcessState = General.Messages.ExtensionError; } } if (model.LogoImage != null) { HttpPostedFileBase postedFileLogo = model.LogoImage; string ext = Path.GetExtension(postedFileLogo.FileName); string fileNameLogo = string.Empty; if (ext == ".jpg" || ext == ".jpeg" || ext == ".png" || ext == ".gif") { Bitmap logoImage = new Bitmap(postedFileLogo.InputStream); Bitmap resizedImageLogo = new Bitmap(logoImage, 100, 100); string uniqueNumberLogo = Guid.NewGuid().ToString(); fileNameLogo = uniqueNumberLogo + postedFileLogo.FileName; resizedImageLogo.Save(Server.MapPath("~/Areas/Admin/Content/favimage/" + fileNameLogo)); model.Logo = fileNameLogo; } else { ViewBag.ProcessState = General.Messages.ExtensionError; } } FavDTO returnDTO = new FavDTO(); returnDTO = bll.UpdateFav(model); if (model.FavImage != null) { if (System.IO.File.Exists(Server.MapPath("~/Areas/Admin/Content/favimage/" + returnDTO.Fav))) { System.IO.File.Delete(Server.MapPath("~/Areas/Admin/Content/favimage/" + returnDTO.Fav)); } } if (model.LogoImage != null) { if (System.IO.File.Exists(Server.MapPath("~/Areas/Admin/Content/favimage/" + returnDTO.Logo))) { System.IO.File.Delete(Server.MapPath("~/Areas/Admin/Content/favimage/" + returnDTO.Logo)); } } ViewBag.ProcessState = General.Messages.UpdateSuccess; } return(View(model)); }
public ActionResult UpdateFav(FavDTO model) { if (!ModelState.IsValid) { ViewBag.ProcessState = General.Messages.EmptyArea; } else { if (model.FavImage != null) { string favname = ""; HttpPostedFileBase postedfilefav = model.FavImage; Bitmap FavImage = new Bitmap(postedfilefav.InputStream); Bitmap resizefavImage = new Bitmap(FavImage, 100, 100); string ext = Path.GetExtension(postedfilefav.FileName); if (ext == ".ico" || ext == ".jpg" || ext == ".jpeg" | ext == ".png") { string favunique = Guid.NewGuid().ToString(); favname = favunique + postedfilefav.FileName; resizefavImage.Save(Server.MapPath("~/Areas/Admin/Content/FavImage/" + favname)); model.Fav = favname; } else { ViewBag.ProcessState = General.Messages.ExtensionError; } } if (model.LogoImage != null) { string logoname = ""; HttpPostedFileBase postedfilelogo = model.LogoImage; Bitmap LogoImage = new Bitmap(postedfilelogo.InputStream); Bitmap resizelogoImage = new Bitmap(LogoImage, 100, 100); string ext = Path.GetExtension(postedfilelogo.FileName); if (ext == ".ico" || ext == ".jpg" || ext == ".jpeg" | ext == ".png") { string logounique = Guid.NewGuid().ToString(); logoname = logounique + postedfilelogo.FileName; resizelogoImage.Save(Server.MapPath("~/Areas/Admin/Content/FavImage/" + logoname)); model.Logo = logoname; } else { ViewBag.ProcessState = General.Messages.ExtensionError; } } FavDTO returndto = new FavDTO(); returndto = bll.UpdateFav(model); if (model.FavImage != null) { if (System.IO.File.Exists(Server.MapPath("~/Areas/Admin/Content/FavImage/" + returndto.Fav))) { System.IO.File.Delete(Server.MapPath("~/Areas/Admin/Content/FavImage/" + returndto.Fav)); } } if (model.LogoImage != null) { if (System.IO.File.Exists(Server.MapPath("~/Areas/Admin/Content/FavImage/" + returndto.Logo))) { System.IO.File.Delete(Server.MapPath("~/Areas/Admin/Content/FavImage/" + returndto.Logo)); } } ViewBag.ProcessState = General.Messages.UpdateSuccess; } return(View(model)); }