public async Task <ActionResult> Edit(PromoEditViewModel model) { if (ModelState.IsValid) { await PromoService.Update(model); return(RedirectToAction("Info", new { id = model.Id })); } return(View(model)); }
public async Task Update(PromoEditViewModel promo) { const string sql = @" UPDATE [dbo].[UserPromo] SET [Description] = @Description, [Active] = @Active WHERE [Id] = @Id"; try { await UnitOfWork.Context().ExecuteAsync(sql, promo); } catch (Exception e) { e.Data["SQL"] = sql; ErrorStore.LogException(e, HttpContext.Current); } }
public async Task <ActionResult> Edit(int id) { PromoViewModel promo = await PromoService.GetPromo(id); if (promo == null) { string message = string.Format("Promo ID {0} not found", id); MvcApplication.LogException(new ArgumentException(message, nameof(id))); return(RedirectToAction("NotFound", "Error")); } PromoEditViewModel model = new PromoEditViewModel() { Id = promo.Id, Description = promo.Description, Active = promo.Active }; return(View(model)); }
public async Task Update(PromoEditViewModel promo) { await PromoRepository.Update(promo); }