private void FillPlaceAdPicsIfAny(EditAdModel model) { if (!model.AdId.HasValue) { return; } var adMedia = _filesService.GetAdMedia(adId: model.AdId.Value); if (adMedia.Success) { foreach (var media in adMedia.Value) { if (media.FileType == FileType.Jpeg) { var smallestFileInfo = media.ScaledPics.OrderBy(x => x.Size.Width).FirstOrDefault(); if (smallestFileInfo == null) { continue; } var editPicModel = new EditAdPicInfoModel(); editPicModel.adMediaId = media.AdMediaId; editPicModel.isMain = media.IsPrimary; editPicModel.relativePicUrl = GetPartialPicUrl(smallestFileInfo.PathParts); model.ExistingPics.Add(editPicModel); } } } }
public ActionResult Edit(EditAdModel model) { if (ModelState.IsValid) { using (var db = new SellPlaceDbContext()) { var ad = db.Ads.Find(model.Id); if (ad == null || !IsAutorized(ad)) { return(HttpNotFound()); } ad.Title = model.Title; ad.Category = model.Category; ad.Discription = model.Discription; ad.Price = model.Price; ad.ImgURL = model.ImgUrl; db.SaveChanges(); } return(RedirectToAction("Details", new { id = model.Id })); } return(View(model)); }
public IActionResult EditAd(long?adId) { var myUser = GetMyUser(); var model = new EditAdModel(); if (adId.HasValue) { var resultAd = _adsService.GetAd(adId: adId.Value); if (!resultAd.Success) { return(BadRequest()); } if (resultAd.Value.UserId != myUser.Id) { return(BadRequest()); } model = _mapper.Map <EditAdModel>(resultAd.Value); } else { model.DateBorn = DateTime.Today.AddYears(-25); model.HeightCm = 165; model.WeightGr = 55000; } FillBaseModel(model); FillPlaceAdCollections(model); FillPlaceAdPicsIfAny(model); return(View(model)); }
public IActionResult EditAd(EditAdModel model) { var myUser = GetMyUser(); var adInfo = _adMapper.GetAdEditInfo(myUser, model); if (!adInfo.Success) { FillBaseModel(model); FillPlaceAdCollections(model); FillPlaceAdPicsIfAny(model); return(View(model)); } var resultEditAd = _adsService.EditAd(adInfo.Value); if (!resultEditAd.Success) { FillBaseModel(model); FillPlaceAdCollections(model); FillPlaceAdPicsIfAny(model); return(View(model)); } return(RedirectToAction(nameof(MyAds))); }
internal Result <AdEditInfo> GetAdEditInfo(UserInfo myUser, EditAdModel model) { var result = new AdEditInfo() { AdId = model.AdId, PlaceId = model.PlaceId, UserId = myUser.Id, Name = HttpUtility.HtmlDecode(model.Name), GenderId = model.GenderId, DateBorn = model.DateBorn, EyeColorId = model.EyeColorId, HairColorId = model.HairColorId, WeightGr = model.WeightGr, HeightCm = model.HeightCm, HairLengthId = model.HairLengthId, MainPicId = model.MainPicId, PicsIds = model.PicsIds, AlcoholId = model.AlcoholId, BodyTypeId = model.BodyTypeId, EducationLevelId = model.EducationLevelId, EthnicGroupId = model.EthnicGroupId, HasKids = model.HasKids, RelationshipStatusId = model.RelationshipStatusId, ReligionId = model.ReligionId, SmokingId = model.SmokingId, ZodiacSignId = model.ZodiacSignId }; return(Result <AdEditInfo> .NewSuccess(result)); }
private void FillPlaceAdCollections(EditAdModel model) { model.MaxPicsAllowed = 10; model.PicIdsSeparator = Consts.PicIdsSeparator; model.EyeColors = ActiveOfType(ObjectTypeCodes.EyeColor); model.HairColors = ActiveOfType(ObjectTypeCodes.HairColor); model.HairLength = ActiveOfType(ObjectTypeCodes.HairLength); model.Genders = ActiveOfType(ObjectTypeCodes.Gender); model.Places = _placesService.GetAllPlaces() .Value .Where(x => x.IsEnabled && x.PlaceType == PlaceType.City) .ToArray(); }
public ActionResult EditAdvertisement(EditAdModel obj) { if (Session["ID"] != null) { var AdID = obj.ID; AddingAdsRepository model = new AddingAdsRepository(); model.CategoryID = -1; model.Categories = addingAdsRepository.GetList(); ADVERTS AdData = new AdvertRepository().GetAdData(AdID); return(View(AdData)); } else { return(RedirectToAction("Logowanie", "Home")); } }
public ActionResult EditAdmin(EditAdModel edit) { var accountad = new Quantri() { adId = Convert.ToInt32(edit.id), password = edit.email }; var user = new AccountAdminDAO().UpdateAdmin(accountad); if (user == true) { return(RedirectToAction("Index")); } ViewBag.TimTaiKhoan = new AccountAdminDAO().ViewDetail(Convert.ToInt32(edit.id)); return(View()); }
public async Task <bool> EditModel(EditAdModel model) { var domain = await _IAdMannageService.GetModelAsync(x => x.Id == model.Id); domain.PosId = model.PosID; domain.PicUrl = model.PicUrl; domain.LinkUrl = model.LinkUrl; domain.Display = model.Istrue ? "是" : "否"; domain.Remark = model.Remark; var data = await _IAdMannageService.Modify(domain); if (data > 0) { return(true); } return(false); }
public ActionResult MojeOgloszenia(string Delete, string Edit) { if (Delete != null) { return(ArchiveAdvertisement(Delete)); } if (Edit != null) { int AdID = Int32.Parse(Edit); //var AdData = new AdvertRepository().GetAdData(AdID); var AdData = new EditAdModel { ID = AdID }; return(RedirectToAction("EditAdvertisement", AdData)); } else { return(View()); } }
public ActionResult Edit(int id) { using (var db = new SellPlaceDbContext()) { var ad = db.Ads.Find(id); if (ad == null || !IsAutorized(ad)) { return(HttpNotFound()); } var editAdModel = new EditAdModel { Title = ad.Title, Category = ad.Category, Discription = ad.Discription, Price = ad.Price, ImgUrl = ad.ImgURL, SellerId = ad.SellerId, }; return(View(editAdModel)); } }