示例#1
0
 public async Task<ActionResult> AddOrUpdate(TemplateEntityViewModel templateEntity)
 {
     if (ModelState.IsValid)
     {
         await _templateService.AddOrUpdateAsync(templateEntity);
         return RedirectToAction("Index");
     }
     templateEntity.CountriesDdl = await _templateService.GetCountriesDropdownAsync();
     return View(templateEntity);
 }
示例#2
0
        public async Task<ActionResult> AddOrUpdate(int id = 0)
        {
            var model = new TemplateEntityViewModel();

            if (id != 0)
            {
                model = await _templateService.GetByIdAsync(id);
                return View("AddOrUpdate", model);
            }

            model.CountriesDdl = await _templateService.GetCountriesDropdownAsync();
            return View(model);
        }
示例#3
0
 public async Task<bool> AddOrUpdateAsync(TemplateEntityViewModel template)
 {
     try
     {
         await _unitOfWork.Repository<TemplateEntity>().AddOrUpdateAsync(template.ToModel());
         await _unitOfWork.Commit();
         return true;
     }
     catch
     {
         return false;
     }
 }