Ejemplo n.º 1
0
        public HttpResponseMessage CancelDelivery(Models.delivery_master deliveryMaster)
        {
            try
            {
                bool success = deliveryRepository.CancelDelivery(deliveryMaster);

                if (success)
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "success", msg = "Courier Information Updated Successfully"
                    },
                                                  formatter));
                }
                else
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Courier Information Updated Failed"
                    },
                                                  formatter));
                }
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }
Ejemplo n.º 2
0
        public HttpResponseMessage UpdateCourierInfo(Models.delivery_master updateCourierInformation)
        {
            try
            {
                if (string.IsNullOrEmpty(updateCourierInformation.delivery_method_id.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK,
                                                  new Confirmation {
                        output = "warning", msg = "Please Select Delivery Method"
                    }, formatter));
                }
                else
                {
                    if (updateCourierInformation.delivery_method_id == 1 && string.IsNullOrEmpty(updateCourierInformation.courier_slip_no))
                    {
                        var formatter = RequestFormat.JsonFormaterString();
                        return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                            output = "warning", msg = "Please Input Courier Slip No."
                        }, formatter));
                    }
                    else if (updateCourierInformation.delivery_method_id == 2)
                    {
                        var formatter = RequestFormat.JsonFormaterString();
                        return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                            output = "warning", msg = "Wrong Delivery Process"
                        }, formatter));
                    }

                    else
                    {
                        var objUpdateCourier = new delivery_master
                        {
                            delivery_master_id = updateCourierInformation.delivery_master_id,
                            courier_slip_no    = updateCourierInformation.courier_slip_no,
                            updated_by         = updateCourierInformation.updated_by
                        };
                        bool success = deliveryRepository.UpdateCourierInfo(objUpdateCourier);

                        if (success)
                        {
                            var formatter = RequestFormat.JsonFormaterString();
                            return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                                output = "success", msg = "Courier Information Updated Successfully"
                            },
                                                          formatter));
                        }
                        else
                        {
                            var formatter = RequestFormat.JsonFormaterString();
                            return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                                output = "error", msg = "Courier Information Updated Failed"
                            },
                                                          formatter));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }
Ejemplo n.º 3
0
        public HttpResponseMessage Put([FromBody] Models.delivery_master updateCourierInformation)
        {
            try
            {
                if (string.IsNullOrEmpty(updateCourierInformation.delivery_method_id.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK,
                                                  new Confirmation {
                        output = "warning", msg = "Please Select Delivery Method"
                    }, formatter));
                }
                else
                {
                    if (updateCourierInformation.delivery_method_id == 1 && string.IsNullOrEmpty(updateCourierInformation.courier_id.ToString()))
                    {
                        var formatter = RequestFormat.JsonFormaterString();
                        return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                            output = "warning", msg = "Please Select Courier Name"
                        }, formatter));
                    }
                    else if (updateCourierInformation.delivery_method_id == 2 && string.IsNullOrEmpty(updateCourierInformation.delivery_person_name))
                    {
                        var formatter = RequestFormat.JsonFormaterString();
                        return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                            output = "warning", msg = "Please Input Delivery Person Name"
                        }, formatter));
                    }

                    else
                    {
                        var objUpdateCourier = new delivery_master
                        {
                            delivery_master_id = updateCourierInformation.delivery_master_id,
                            delivery_method_id = updateCourierInformation.delivery_method_id,
                            updated_by         = updateCourierInformation.updated_by
                        };
                        if (updateCourierInformation.delivery_method_id == 1)
                        {
                            objUpdateCourier.courier_id = updateCourierInformation.courier_id;
                        }
                        else if (updateCourierInformation.delivery_method_id == 2)
                        {
                            objUpdateCourier.delivery_person_name = updateCourierInformation.delivery_person_name;
                        }

                        bool success = deliveryRepository.UpdateDeliveryMethod(objUpdateCourier);

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