public ActionResult Edit(PersonModel personModel) { try { if (ModelState.IsValid) { PersonDto personDto = Mapper.Map <PersonDto>(personModel); if (personModel.Id == 0) { personBl.Insert(personDto); } else { personBl.Update(personDto); } UnitOfWorkBl.Save(); } return(View(personModel)); } catch (Exception ex) { return(null); } }
private void Application_EndRequest(Object sender, EventArgs e) { if (!IsMediaRequest()) { string message = String.Format("End of httpRequest - RequestUrl = {1} - duration : {0:N0} ms ", HttpContext.Current.Request.Url, (DateTime.Now - HttpContext.Current.Timestamp).TotalMilliseconds); _logger.Log(LogLevel.Info, message); UnitOfWorkBl.DisposeUow(); } }
private void Application_BeginRequest(Object sender, EventArgs e) { if (!IsMediaRequest()) { UnitOfWorkBl.InitUow(); string message = String.Format("Starting a new httprequest - RequestUrl = {0} ", HttpContext.Current.Request.Url); _logger.Log(LogLevel.Info, message); } }
public JsonResult UpdateData(string oper, string id) { if (String.Compare(oper, "del", StringComparison.Ordinal) == 0) { int iOut; if (int.TryParse(id, out iOut)) { personBl.DeleteById(iOut); UnitOfWorkBl.Save(); // no exception, the item was successfully deleted return(Json(null)); } ArgumentException exDataNotDeleted = new ArgumentException("No data could be deleted", "id"); throw exDataNotDeleted; } ArgumentException exUnknownOperation = new ArgumentException("Unknown editing operation", "oper"); throw exUnknownOperation; }