Exemple #1
0
        public async Task <ActionResult> Create(PartnerViewModel partnerVm)
        {
            if (!ModelState.IsValid)
            {
                return(View(partnerVm));
            }

            _partnerRepository.Add(partnerVm.Map <Partner>());

            await UnitOfWork.CompleteAsync();

            return(View("List"));
        }
Exemple #2
0
        public async Task <ActionResult> Update(int id, PartnerViewModel partnerVm)
        {
            if (!ModelState.IsValid)
            {
                return(View(partnerVm));
            }

            var partnerInDb = await _partnerRepository.GetAsync(id);

            if (partnerInDb == null)
            {
                return(View(partnerVm));
            }

            partnerInDb = partnerVm.Map <Partner>();

            _partnerRepository.Add(partnerInDb);

            await UnitOfWork.CompleteAsync();

            return(RedirectToAction("List"));
        }