예제 #1
0
        public HttpResponseMessage Put([FromBody] Models.receive receive)
        {
            try
            {
                if (string.IsNullOrEmpty(receive.receive_date.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "warning", msg = "Please Select Receive Date"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(receive.party_id.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "warning", msg = "Please Select Channel Name"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(receive.bank_account_id.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "warning", msg = "Please Enter Account Number"
                    }, formatter));
                }


                if (string.IsNullOrEmpty(receive.payment_method_id.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "warning", msg = "Please Select Payment Method"
                    }, formatter));
                }

                //if (receive.payment_method_id == 3 && string.IsNullOrEmpty(receive.cheque_no))
                //{
                //    var checkNoFormatter = RequestFormat.JsonFormaterString();
                //    return Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "warning", msg = "Please Insert Check Or Slip No" }, checkNoFormatter);

                //}


                if (receive.payment_method_id == 3 && receive.bank_id == null)
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "warning", msg = "Please Select Bank Name"
                    }, formatter));
                }


                if (receive.payment_method_id == 3 && receive.bank_branch_id == null)
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "warning", msg = "Please Select Bank Branch Name"
                    }, formatter));
                }

                if (string.IsNullOrEmpty(receive.amount.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "warning", msg = "Please Insert Amount"
                    }, formatter));
                }



                else
                {
                    receive UpdateReceive = new receive
                    {
                        receive_id          = receive.receive_id,
                        receive_date        = receive.receive_date,
                        party_id            = receive.party_id,
                        payment_method_id   = receive.payment_method_id,
                        cheque_no           = receive.cheque_no,
                        bank_id             = receive.bank_id,
                        bank_branch_id      = receive.bank_branch_id,
                        bank_account_id     = receive.bank_account_id,
                        amount              = receive.amount,
                        invoice_no          = receive.invoice_no,
                        representative      = receive.representative,
                        remarks             = receive.remarks,
                        payment_req_id      = receive.payment_req_id,
                        document_attachment = receive.document_attachment,
                        bank_charge         = receive.bank_charge,
                        is_varified         = receive.is_varified,
                        updated_date        = DateTime.Now,
                        updated_by          = receive.updated_by
                    };

                    receiveRepository.EditReceive(UpdateReceive);


                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "success", msg = "Received Amount Updated Successfully"
                    }, formatter));
                }
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }