Пример #1
0
        public HttpResponseMessage Put([FromBody] Models.warehouse warehouse)
        {
            try
            {
                if (string.IsNullOrEmpty(warehouse.warehouse_name))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Warehouse Name is Empty"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(warehouse.warehouse_type.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Please Select Warehouse Type"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(warehouse.region_id.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Please Select Region "
                    }, formatter));
                }
                if (string.IsNullOrEmpty(warehouse.area_id.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Please Select Area"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(warehouse.territory_id.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Please Select Territory"
                    }, formatter));
                }
                else
                {
                    Models.warehouse updatewarehouse = new Models.warehouse
                    {
                        warehouse_id      = warehouse.warehouse_id,
                        warehouse_name    = warehouse.warehouse_name,
                        warehouse_code    = warehouse.warehouse_code,
                        warehouse_address = warehouse.warehouse_address,
                        warehouse_type    = warehouse.warehouse_type,
                        region_id         = warehouse.region_id,
                        area_id           = warehouse.area_id,
                        territory_id      = warehouse.territory_id,
                        is_deleted        = false,
                        is_active         = warehouse.is_active,
                        updated_by        = warehouse.updated_by,
                        updated_date      = DateTime.Now
                    };

                    warehouseRepository.EditWarehouse(updatewarehouse);
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "success", msg = "Warehouse updated successfully"
                    }, formatter));
                }
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }