示例#1
0
        public ActionResult CreateEdit(UWareHouse wareHouse, string Action = "")
        {
            if (ModelState.IsValid)
            {
                if (!wareHouse._wareHouse.Id.Equals(Guid.Empty))
                {
                    wareHouse._wareHouse.CountryProgrammeId = countryProg.Id;
                    if (wareHouseService.EditWareHouse(wareHouse._wareHouse))
                    {
                        ModelState.Clear();
                        wareHouse = new UWareHouse();
                    }
                }
                else
                {
                    wareHouse._wareHouse.CountryProgrammeId = countryProg.Id;
                    if (wareHouseService.AddWareHouse(wareHouse._wareHouse))
                    {
                        ModelState.Clear();
                        wareHouse = new UWareHouse();
                    }
                }
            }


            wareHouse.LocationSelect =
                new SelectList(wareHouseService.LocationObj.GetLocations(), "Id", "Name");

            wareHouse.SubOffSelect = new SelectList(wareHouseService.CtrySubOffObj.GetCountrySubOffices(countryProg.Id),
                                                    "Id", "Address");
            return(ListView());
        }
        public async Task <IActionResult> Post([FromBody] WareHouseBindingModel model)
        {
            var warehouse = await _warehouseService.AddWareHouse(_mapper.Map <WareHouse>(model));

            return(Ok(_mapper.Map <WareHouseBindingModel>(warehouse)));
        }