public dynamic PutStore(StoresVM s) { var store = db.Stores.Find(s.Id); store.Address = s.Address; store.RegionId = s.RegionId; store.CityId = s.CityId; store.Phone = s.Phone; store.StoreManagerId = s.StoreManagerId; var result = db.SaveChanges() > 0 ? true : false; return(new { result = result }); }
public dynamic PostStore(StoresVM s) { var store = db.Stores.Add(new Store { Address = s.Address, RegionId = s.RegionId, CityId = s.CityId, Phone = s.Phone, StoreManagerId = s.StoreManagerId }); var result = db.SaveChanges() > 0 ? true : false; return(new { result = result, storeId = store.Id }); }
public IActionResult CreateStore([FromBody] StoresVM storeVm) { if (storeVm == null || string.IsNullOrEmpty(storeVm.Store_name) || string.IsNullOrEmpty(storeVm.Token)) { return(Ok(new { success = false, message = "Недопустимый формат" })); } var userId = _userRepository.GetByToken(storeVm.Token); var store = new Stores { UserId = userId.Id, Store_name = storeVm.Store_name, Description = storeVm.Description, Type = storeVm.Type }; _storesRepository.Add(store); return(Ok(new { success = true, message = "Новый магазин успешно создан" })); }