コード例 #1
0
        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
            });
        }
コード例 #2
0
        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
            });
        }
コード例 #3
0
ファイル: StoreController.cs プロジェクト: Accvad/HandyMady
        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 = "Новый магазин успешно создан" }));
        }