Exemplo n.º 1
0
        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);
                    }
                }
            }
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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)));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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();
        }
Exemplo n.º 7
0
        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());
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
 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());
     }
 }
Exemplo n.º 11
0
        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));
            }
        }