public long UpdateDocumentTypeRight(DocumentTypeRightObject documentTypeRight) { try { if (documentTypeRight == null) { return(-2); } var documentTypeRightEntity = ModelMapper.Map <DocumentTypeRightObject, DocumentTypeRight>(documentTypeRight); if (documentTypeRightEntity == null || documentTypeRightEntity.DocumentTypeRightId < 1) { return(-2); } using (var db = new ImportPermitEntities()) { db.DocumentTypeRights.Attach(documentTypeRightEntity); db.Entry(documentTypeRightEntity).State = EntityState.Modified; db.SaveChanges(); return(documentTypeRight.DocumentTypeRightId); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
public long AddDocumentTypeRight(DocumentTypeRightObject documentTypeRight) { try { if (documentTypeRight == null) { return(-2); } var documentTypeRightEntity = ModelMapper.Map <DocumentTypeRightObject, DocumentTypeRight>(documentTypeRight); if (documentTypeRightEntity == null || documentTypeRightEntity.DocumentTypeId < 1) { return(-2); } using (var db = new ImportPermitEntities()) { var returnStatus = db.DocumentTypeRights.Add(documentTypeRightEntity); db.SaveChanges(); return(returnStatus.DocumentTypeRightId); } } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }
private GenericValidator ValidateDocumentTypeRight(DocumentTypeRightObject documentTypeRight) { var gVal = new GenericValidator(); try { if (string.IsNullOrEmpty(documentTypeRight.RoleId)) { gVal.Code = -1; gVal.Error = "Please select a Role."; return(gVal); } if (documentTypeRight.DocumentTypeId < 1) { gVal.Code = -1; gVal.Error = "Please select Document Type."; return(gVal); } gVal.Code = 5; return(gVal); } catch (Exception) { gVal.Code = -1; gVal.Error = "Document Right Validation failed. Please provide all required fields and try again."; return(gVal); } }
public long UpdateDocumentTypeRight(DocumentTypeRightObject documentTypeRight) { try { return(_documentTypeRightManager.UpdateDocumentTypeRight(documentTypeRight)); } catch (Exception ex) { ErrorLogger.LoggError(ex.StackTrace, ex.Source, ex.Message); return(0); } }