Exemplo n.º 1
0
        // POST: Stores
        public ActionResult Create(StoreDto dto)
        {
            Store store = Store.FromNameAndAddress(dto.name, dto.address);

            try
            {
                return(toContent(storeService.Save(store)));
            }
            catch (DbEntityValidationException e)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, e.Message));
            }
        }
Exemplo n.º 2
0
        public ActionResult Update(int?id, StoreDto dto)
        {
            var store = storeService.FindOne(id.Value);

            if (store == null)
            {
                return(HttpNotFound($"id ${id} not found"));
            }
            try
            {
                return(toContent(storeService.Update(store, dto.name, dto.address)));
            }
            catch (DbEntityValidationException e)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, e.Message));
            }
        }