示例#1
0
 public ResModel AddWarehouse(WarehouseDto warehouseDto, UserDto operationUser)
 {
     return(_warehouseRepository.AddWarehouse(warehouseDto, operationUser));
 }
        public HttpResponseMessage Post([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.party_id.ToString()))
                //{
                //    var formatter = RequestFormat.JsonFormaterString();
                //    return Request.CreateResponse(HttpStatusCode.OK, new Confirmation { output = "error", msg = "Please Select Party" }, formatter);

                //}

                else
                {
                    if (warehouseRepository.CheckDuplicateWarehouse(warehouse.warehouse_name))
                    {
                        var formatter = RequestFormat.JsonFormaterString();
                        return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                            output = "error", msg = "Warehouse Already Exists"
                        }, formatter));
                    }
                    else
                    {
                        warehouse insert_warehouse = new warehouse
                        {
                            warehouse_name    = warehouse.warehouse_name,
                            warehouse_address = warehouse.warehouse_address,
                            warehouse_code    = warehouse.warehouse_code,
                            region_id         = warehouse.region_id,
                            area_id           = warehouse.area_id,
                            territory_id      = warehouse.territory_id,
                            is_active         = true,
                            is_deleted        = false,
                            created_by        = warehouse.created_by,
                            warehouse_type    = warehouse.warehouse_type
                        };

                        warehouseRepository.AddWarehouse(insert_warehouse);
                        var formatter = RequestFormat.JsonFormaterString();
                        return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                            output = "success", msg = "Warehouse saved successfully"
                        }, formatter));
                    }
                }
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }
 public void AddWarehouse(Warehouse warehouse)
 {
     warehouseRepo.AddWarehouse(warehouse);
 }
        public int WarehouseAdd(IOT.Core.Model.Warehouse a)
        {
            int i = _warehouse.AddWarehouse(a);

            return(i);
        }