private static InvoiceType getEntityByModel(InvoiceTypeModel model) { if (model == null) return null; InvoiceType entity = new InvoiceType(); 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.Meaning = model.Meaning; entity.SOBId = model.SOBId; entity.Invoicetype = model.InvoiceType; entity.Id = model.Id; entity.Description = model.Description; entity.DateTo = model.DateTo; entity.DateFrom = model.DateFrom; entity.UpdateBy = AuthenticationHelper.UserId; entity.UpdateDate = DateTime.Now; return entity; }
public static string Save(InvoiceTypeModel model) { if (model.Id > 0) { return service.Update(getEntityByModel(model)); } else { return service.Insert(getEntityByModel(model)); } }
public ActionResult DeleteInline(InvoiceTypeModel model) { if (ModelState.IsValid) { try { InvoiceTypeHelper.Delete(model.Id.ToString()); return PartialView("_List", InvoiceTypeHelper.GetInvoiceTypes(SessionHelper.SOBId)); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else ViewData["EditError"] = "Please, correct all errors."; return PartialView("_List", InvoiceTypeHelper.GetInvoiceTypes(SessionHelper.SOBId)); }