private static Warehouse getEntityByModel(WarehouseModel model) { if (model == null) return null; Warehouse entity = new Warehouse(); if (model.Id == 0) { entity.CreateBy = AuthenticationHelper.UserId; entity.CreateDate = DateTime.Now; entity.CompanyId = AuthenticationHelper.CompanyId.Value; } else { entity.CreateBy = model.CreateBy; entity.CreateDate = model.CreateDate; entity.CompanyId = model.CompanyId; } entity.WarehouseName = model.WarehouseName; entity.Id = model.Id; entity.SOBId = model.SOBId; entity.Status = model.Status; entity.UpdateBy = AuthenticationHelper.UserId; entity.UpdateDate = DateTime.Now; return entity; }
public static string Save(WarehouseModel model) { if (model.Id > 0) { return service.Update(getEntityByModel(model)); } else { return service.Insert(getEntityByModel(model)); } }
public ActionResult DeleteInline(WarehouseModel model) { if (ModelState.IsValid) { try { WarehouseHelper.Delete(model.Id.ToString()); return PartialView("_List", WarehouseHelper.GetWarehouses(SessionHelper.SOBId)); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else ViewData["EditError"] = "Please, correct all errors."; return PartialView("_List", WarehouseHelper.GetWarehouses(SessionHelper.SOBId)); }
public ActionResult UpdateInline(WarehouseModel model) { if (ModelState.IsValid) { try { model.CompanyId = AuthenticationHelper.CompanyId.Value; model.SOBId = SessionHelper.SOBId; WarehouseHelper.Save(model); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else ViewData["EditError"] = "Please, correct all errors."; return PartialView("_List", WarehouseHelper.GetWarehouses(SessionHelper.SOBId)); }