/// <summary> /// Create New Section /// </summary> /// <param name="model"></param> /// <returns></returns> public static SignDocumentSectionModel Create(SignDocumentSectionModel model, Guid idDocument) { using (UpsilabEntities context = new UpsilabEntities()) { model.IdDocumentModel = idDocument; model.DateCreated = DateTime.Now; var entity = ModelToEntity(model); context.DocumentSection.AddObject(entity); context.SaveChanges(); model.IdDocumentSection = entity.IdDocumentSection; } return model; }
private static DocumentSection ModelToEntity(SignDocumentSectionModel model) { var entity = new DocumentSection { IdDocumentModel = model.IdDocumentModel, NameKey = model.NameKey, DateCreated = model.DateCreated }; if (model.IdDocumentSection != null) entity.IdDocumentSection = model.IdDocumentSection.GetValueOrDefault(); return entity; }
public JsonResult AddSection(SignDocumentSectionModel section, Guid idDocument) { try { DocumentSectionBL.Create(section, idDocument); return Json(new { success = true, msg = "", section = section}, JsonRequestBehavior.AllowGet); } catch (Exception e) { return Json(new { success = false, msg = e.Message }, JsonRequestBehavior.AllowGet); } }