Esempio n. 1
0
        public IHttpActionResult CreateStore([FromBody] StoreSummary storeSummary)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            return(Ok(storeService.CreateStore(storeSummary)));
        }
        public Store EditStore(StoreSummary storeSummary, int storeId)
        {
            var store = storeRepository.GetById(storeId);

            store.State   = storeSummary.State;
            store.Address = storeSummary.Address;
            store.City    = storeSummary.City;
            store.Email   = storeSummary.Email;
            store.Name    = storeSummary.Name;
            store.Phone   = storeSummary.Phone;
            return(storeRepository.ModifyStore(store));
        }
Esempio n. 3
0
 public IHttpActionResult UpdateStore([FromUri] int storeId, [FromBody] StoreSummary storeSummary)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         return(Ok(storeService.EditStore(storeSummary, storeId)));
     }
     catch (InvalidOperationException)
     {
         return(BadRequest($"Store with id {storeId} does not exists"));
     }
 }
        public Store CreateStore(StoreSummary storeSummary)
        {
            //todo mapper
            var store = new Store()
            {
                State   = storeSummary.State,
                Address = storeSummary.Address,
                City    = storeSummary.City,
                Email   = storeSummary.Email,
                Name    = storeSummary.Name,
                Phone   = storeSummary.Phone
            };

            return(storeRepository.AddStore(store));
        }