예제 #1
0
        public AdvertiseContractViewModel Add(AdvertiseContractViewModel advertiseContractViewModel)
        {
            var AdvertiseContract = Mapper.Map <AdvertiseContractViewModel, AdvertiseContract>(advertiseContractViewModel);
            var a = _advertiseContractRepository.AddReturn(AdvertiseContract);

            advertiseContractViewModel.KeyId = a.KeyId;
            return(advertiseContractViewModel);
        }
예제 #2
0
        public void Update(AdvertiseContractViewModel advertiseContractViewModel)
        {
            var temp = _advertiseContractRepository.FindById(advertiseContractViewModel.KeyId);

            if (temp != null)
            {
                temp.ContractValue = advertiseContractViewModel.ContractValue;
                temp.DateStart     = advertiseContractViewModel.DateStart;
                temp.DateFinish    = advertiseContractViewModel.DateFinish;
                temp.Status        = advertiseContractViewModel.Status;
            }
        }
 public IActionResult SaveEntity(AdvertisementContentViewModel adContentVm, AdvertiseContractViewModel advertiseContractVm)
 {
     if (!ModelState.IsValid)
     {
         IEnumerable <ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors);
         return(new BadRequestObjectResult(allErrors));
     }
     else
     {
         if (advertiseContractVm.KeyId == 0)
         {
             var _adContent = _advertisementContentService.Add(adContentVm);
             advertiseContractVm.AdvertisementContentFK = _adContent.KeyId;
             _advertiseContractService.Add(advertiseContractVm);
         }
         else
         {
             _advertisementContentService.Update(adContentVm);
             _advertiseContractService.Update(advertiseContractVm);
         }
         _advertiseContractService.Save();
         return(new OkObjectResult(advertiseContractVm));
     }
 }