Exemplo n.º 1
0
        public async Task <IActionResult> DeleteAsync(int id, Model model)
        {
            if (ModelState.IsValid == false)
            {
                return(RedirectToAction("Delete", new { id, error = GetModelStateError() }));
            }
            try
            {
                using var ctrl = Factory.Create <Contract>(SessionWrapper.SessionToken);

                await ctrl.DeleteAsync(id).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Delete", new { id, error = GetExceptionError(ex) }));
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> EditAsync(int id, Model model)
        {
            if (ModelState.IsValid == false)
            {
                model.ActionError = GetModelStateError();
                return(View(model));
            }
            try
            {
                using var ctrl = Factory.Create <Contract>(SessionWrapper.SessionToken);

                await ctrl.UpdateAsync(model).ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                model.ActionError = GetExceptionError(ex);
                return(View(model));
            }
            return(RedirectToAction("Index"));
        }