Esempio n. 1
0
        public ApprovalTypeModel UpdateApprovalType(ApprovalTypeModel approvalTypeModel)
        {
            _approvalTypes.ReplaceOne(approvalType => approvalType.approvalCode.Equals(approvalTypeModel.approvalCode), approvalTypeModel);
            ApprovalTypeModel tmpApprovalTypeModel = GetOneApprovalTypeByCode(approvalTypeModel.approvalCode);

            return(tmpApprovalTypeModel);
        }
Esempio n. 2
0
        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());
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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));
     }
 }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
 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);
     }
 }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        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));
            }
        }
Esempio n. 16
0
        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());
            }
        }
Esempio n. 17
0
 static public OleDbCommand UpdateApprovalType(ApprovalTypeModel approvalTypeModel)
 {
     return(CreateOleDbCommand(approvalTypeModel, queryApprovalTypesUpdate));
 }
Esempio n. 18
0
 static public OleDbCommand AddApprovalType(ApprovalTypeModel approvalTypeModel)
 {
     return(CreateOleDbCommand(approvalTypeModel, queryApprovalTypesPost));
 }