public ApprovalTypeModel UpdateApprovalType(ApprovalTypeModel approvalTypeModel) { _approvalTypes.ReplaceOne(approvalType => approvalType.approvalCode.Equals(approvalTypeModel.approvalCode), approvalTypeModel); ApprovalTypeModel tmpApprovalTypeModel = GetOneApprovalTypeByCode(approvalTypeModel.approvalCode); return(tmpApprovalTypeModel); }
public ApprovalTypeModel UpdateApprovalType(ApprovalTypeModel approvalTypeModel) { var resultSP = DB.UpdateApprovalType(approvalTypeModel.approvalCode, approvalTypeModel.approvalName).Select(a => new ApprovalTypeModel { approvalCode = a.approvalCode, approvalName = a.approvalName }); if (GlobalVariable.queryType == 0) { APPROVALTYPE approvalType = DB.APPROVALTYPES.Where(a => a.approvalCode.Equals(approvalTypeModel.approvalCode)).SingleOrDefault(); if (approvalType == null) { return(null); } approvalType.approvalCode = approvalTypeModel.approvalCode; approvalType.approvalName = approvalTypeModel.approvalName; DB.SaveChanges(); return(GetOneApprovalTypeByCode(approvalType.approvalCode)); } else { return(resultSP.SingleOrDefault()); } }
static private OleDbCommand CreateOleDbCommand(ApprovalTypeModel approvalType, string commandText) { OleDbCommand command = new OleDbCommand(commandText); command.Parameters.AddWithValue("@approvalCode", approvalType.approvalCode); command.Parameters.AddWithValue("@approvalName", approvalType.approvalName); return(command); }
public static ApprovalTypeModel ToObject(DataRow reader) { ApprovalTypeModel approvalTypeModel = new ApprovalTypeModel(); approvalTypeModel.approvalCode = reader[0].ToString(); approvalTypeModel.approvalName = reader[1].ToString(); Debug.WriteLine("ApprovalTypeModel:" + approvalTypeModel.ToString()); return(approvalTypeModel); }
public ApprovalTypeModel AddApprovalType(ApprovalTypeModel approvalTypeModel) { if (_approvalTypes.Find <ApprovalTypeModel>(Builders <ApprovalTypeModel> .Filter.Eq(approvalType => approvalType.approvalCode, approvalTypeModel.approvalCode)).FirstOrDefault() == null) { _approvalTypes.InsertOne(approvalTypeModel); } ApprovalTypeModel tmpApprovalTypeModel = GetOneApprovalTypeByCode(approvalTypeModel.approvalCode); return(tmpApprovalTypeModel); }
public ApprovalTypeModel UpdateApprovalType(ApprovalTypeModel approvalTypeModel) { int i = -1; using (OleDbCommand command = new OleDbCommand()) { i = ExecuteNonQuery(ApprovalTypeStringsInner.UpdateApprovalType(approvalTypeModel)); } return(GetOneApprovalTypeByCode(approvalTypeModel.approvalCode)); }
static public SqlCommand UpdateApprovalType(ApprovalTypeModel approvalTypeModel) { if (GlobalVariable.queryType == 0) { return(CreateSqlCommand(approvalTypeModel, queryApprovalTypesUpdate)); } else { return(CreateSqlCommand(approvalTypeModel, procedureApprovalTypesUpdate)); } }
public HttpResponseMessage GetOneApprovalTypeByCode(string approvalCode) { try { ApprovalTypeModel approvalTypeModel = approvalTypesRepository.GetOneApprovalTypeByCode(approvalCode); return(Request.CreateResponse(HttpStatusCode.OK, approvalTypeModel)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors)); } }
public List <ApprovalTypeModel> GetAllApprovalTypes() { DataTable dt = new DataTable(); List <ApprovalTypeModel> arrApprovalType = new List <ApprovalTypeModel>(); using (OleDbCommand command = new OleDbCommand()) { dt = GetMultipleQuery(ApprovalTypeStringsInner.GetAllApprovalTypes()); } foreach (DataRow ms in dt.Rows) { arrApprovalType.Add(ApprovalTypeModel.ToObject(ms)); } return(arrApprovalType); }
public ApprovalTypeModel UpdateApprovalType(ApprovalTypeModel approvalTypeModel) { DataTable dt = new DataTable(); using (SqlCommand command = new SqlCommand()) { dt = GetMultipleQuery(ApprovalTypeStringsSql.UpdateApprovalType(approvalTypeModel)); } foreach (DataRow ms in dt.Rows) { approvalTypeModel = ApprovalTypeModel.ToObject(ms); } return(approvalTypeModel); }
public ApprovalTypeModel GetOneApprovalTypeByCode(string approvalCode) { DataTable dt = new DataTable(); ApprovalTypeModel approvalModelType = new ApprovalTypeModel(); using (OleDbCommand command = new OleDbCommand()) { dt = GetMultipleQuery(ApprovalTypeStringsInner.GetOneApprovalTypeByCode(approvalCode)); } foreach (DataRow ms in dt.Rows) { approvalModelType = ApprovalTypeModel.ToObject(ms); } return(approvalModelType); }
public HttpResponseMessage AddApprovalType(ApprovalTypeModel approvalTypeModel) { try { HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.Created) { Content = new StringContent(JsonConvert.SerializeObject(approvalTypesRepository.AddApprovalType(approvalTypeModel))) }; return(hrm); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); HttpResponseMessage hr = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(errors.ToString()) }; return(hr); } }
public ApprovalTypeModel GetOneApprovalTypeByCode(string approvalCode) { DataTable dt = new DataTable(); if (approvalCode.Equals(string.Empty) || approvalCode.Equals("")) { throw new ArgumentOutOfRangeException(); } ApprovalTypeModel approvalModelType = new ApprovalTypeModel(); using (SqlCommand command = new SqlCommand()) { dt = GetMultipleQuery(ApprovalTypeStringsSql.GetOneApprovalTypeByCode(approvalCode)); } foreach (DataRow ms in dt.Rows) { approvalModelType = ApprovalTypeModel.ToObject(ms); } return(approvalModelType); }
public HttpResponseMessage UpdateApprovalType(string updateByCode, ApprovalTypeModel approvalTypeModel) { try { approvalTypeModel.approvalCode = updateByCode; ApprovalTypeModel updatedApprovalType = approvalTypesRepository.UpdateApprovalType(approvalTypeModel); HttpResponseMessage hrm = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(JsonConvert.SerializeObject(updatedApprovalType)) }; return(hrm); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); HttpResponseMessage hr = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(errors.ToString()) }; return(hr); } }
public HttpResponseMessage AddApprovalType(ApprovalTypeModel approvalTypeModel) { try { if (approvalTypeModel == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Data is null.")); } if (!ModelState.IsValid) { Errors errors = ErrorsHelper.GetErrors(ModelState); return(Request.CreateResponse(HttpStatusCode.BadRequest, errors)); } ApprovalTypeModel addedApprovalType = approvalTypesRepository.AddApprovalType(approvalTypeModel); return(Request.CreateResponse(HttpStatusCode.Created, addedApprovalType)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, errors)); } }
public ApprovalTypeModel AddApprovalType(ApprovalTypeModel approvalTypeModel) { var resultSP = DB.AddApprovalType(approvalTypeModel.approvalCode, approvalTypeModel.approvalName).Select(a => new ApprovalTypeModel { approvalCode = a.approvalCode, approvalName = a.approvalName }); if (GlobalVariable.queryType == 0) { APPROVALTYPE approvalType = new APPROVALTYPE { approvalCode = approvalTypeModel.approvalCode, approvalName = approvalTypeModel.approvalName }; DB.APPROVALTYPES.Add(approvalType); DB.SaveChanges(); return(GetOneApprovalTypeByCode(approvalType.approvalCode)); } else { return(resultSP.SingleOrDefault()); } }
static public OleDbCommand UpdateApprovalType(ApprovalTypeModel approvalTypeModel) { return(CreateOleDbCommand(approvalTypeModel, queryApprovalTypesUpdate)); }
static public OleDbCommand AddApprovalType(ApprovalTypeModel approvalTypeModel) { return(CreateOleDbCommand(approvalTypeModel, queryApprovalTypesPost)); }