Example #1
0
        public async Task <ActionResult> CreateStoreAsync([FromBody] CreateStoreRequestModel storeModel)
        {
            var store = new Store(storeModel.Name, storeModel.StoreTypeId);

            _storeRepository.Add(store);
            await _storeRepository.UnitOfWork.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetByIdAsync), new { id = store.Id }, null));
        }
Example #2
0
 public static Store MapAsNewEntity(this CreateStoreRequestModel model)
 {
     return(new Store
     {
         Name = model.Name,
         Branch = model.Branch,
         Address = model.Address,
         Employees = model.Employees
     });
 }
Example #3
0
        public async Task <ActionResult <StoreDto> > CreateStore([FromBody] CreateStoreRequestModel requestModel)
        {
            StoreDto responseModel = await storeService.CreateStore(
                new CreateStoreDto
            {
                Name        = requestModel.Name,
                Description = requestModel.Description,
                BrandId     = requestModel.BrandId,
                Address     = requestModel.Address,
                Location    = new GeoEntry {
                    Longitude = requestModel.Longitude, Latitude = requestModel.Latitude
                }
            });

            if (responseModel == null)
            {
                return(InvalidRequest());
            }

            return(CreatedAtAction(nameof(CreateStore), new { id = responseModel.Id }, responseModel));
        }