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); }
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); }
public async Task<bool> AddOrUpdateAsync(TemplateEntityViewModel template) { try { await _unitOfWork.Repository<TemplateEntity>().AddOrUpdateAsync(template.ToModel()); await _unitOfWork.Commit(); return true; } catch { return false; } }