public AdvertisementContentViewModel Add(AdvertisementContentViewModel advertisementContentViewModel)
        {
            var advertisementContent = Mapper.Map <AdvertisementContentViewModel, AdvertisementContent>(advertisementContentViewModel);
            var a = _advertisementContentRepository.AddReturn(advertisementContent);

            advertisementContentViewModel.KeyId = a.KeyId;
            return(advertisementContentViewModel);
        }
        public void Update(AdvertisementContentViewModel AdvertisementContentViewModel)
        {
            var temp = _advertisementContentRepository.FindById(AdvertisementContentViewModel.KeyId);

            if (temp != null)
            {
                temp.UrlToAdvertisement = AdvertisementContentViewModel.UrlToAdvertisement;
                temp.Title       = AdvertisementContentViewModel.Title;
                temp.ImageLink   = AdvertisementContentViewModel.ImageLink;
                temp.Description = AdvertisementContentViewModel.Description;
            }
        }
        public void UpdateUnqualifiedAdContent(AdvertisementContentViewModel adContentVm)
        {
            var temp = _advertisementContentRepository.FindById(adContentVm.KeyId);

            if (temp != null)
            {
                temp.CensorStatus       = CensorStatus.Uncensored;
                temp.CensorFK           = null;
                temp.Note               = adContentVm.Note;
                temp.Title              = adContentVm.Title;
                temp.UrlToAdvertisement = adContentVm.UrlToAdvertisement;
                if (adContentVm.ImageLink != null)
                {
                    temp.ImageLink = adContentVm.ImageLink;
                }
            }
        }
 public IActionResult SaveEntity(AdvertisementContentViewModel advertisementContentVm)
 {
     if (!ModelState.IsValid)
     {
         IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors);
         return(new BadRequestObjectResult(allErrors));
     }
     else
     {
         if (advertisementContentVm.KeyId == 0)
         {
             _advertisementContentService.Add(advertisementContentVm);
         }
         else
         {
             _advertisementContentService.Update(advertisementContentVm);
         }
         _advertisementPositionService.Save();
         return(new OkObjectResult(advertisementContentVm));
     }
 }
 public IActionResult UpdateUnqualifiedAdContent(AdvertisementContentViewModel adContentVm)
 {
     _advertisementContentService.UpdateUnqualifiedAdContent(adContentVm);
     _advertisementContentService.Save();
     return(new OkObjectResult("true"));
 }