Beispiel #1
0
        public ActionResult Create(BranchOfficeForm shopForm)
        {
            if (!ModelState.IsValid)
            {
                return(View(shopForm));
            }

            var shop = shopForm.ToBranchOffice();

            shop.ShopId = _currentUser.Shop.Id;

            _branchOfficeService.Create(shop);

            return(RedirectToAction("Index", new { shopId = shopForm.ShopId }).WithSuccess("Sucursal Creada"));
        }
Beispiel #2
0
        public IActionResult CreateOffice([FromBody] BranchOfficeDTO office)
        {
            if (office == null)
            {
                return(BadRequest());
            }

            var cityId = office.CityId;

            if (!_branchOfficeService.CityExists(cityId))
            {
                return(NotFound());
            }

            if (_branchOfficeService.OfficeExistsByCityId(cityId))
            {
                return(BadRequest());
            }
            else
            {
                var newOffice = _branchOfficeService.Create(office);
                return(Ok(newOffice));
            }
        }