public Database.Schema.Entity.DocumentType AddDocumentType(DocumentTypeManagement documentTypeManagement) { var documentType = db.DocumentTypes.Add(new Database.Schema.Entity.DocumentType { IsRequired = documentTypeManagement.IsRequired, Name = documentTypeManagement.Name, Description = documentTypeManagement.Description }); db.SaveChanges(); return(documentType); }
public IHttpActionResult EditDocumentType([FromBody] DocumentTypeManagement documentType, int id) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } return(Ok(_documentManagementService.EditDocumentType(documentType, id))); } catch (System.Exception e) { return(InternalServerError(e)); } }
public DocumentTypeDto EditDocumentType(DocumentTypeManagement documentTypeManagement, int id) { db.DocumentTypes.Where(x => x.Id == id && !x.DelFlag).Update(x => new Database.Schema.Entity.DocumentType { IsRequired = documentTypeManagement.IsRequired, Name = documentTypeManagement.Name, Description = documentTypeManagement.Description }); db.SaveChanges(); return(new DocumentTypeDto { Id = id, IsRequired = documentTypeManagement.IsRequired, Name = documentTypeManagement.Name, Description = documentTypeManagement.Description }); }