예제 #1
0
        public async Task <IHttpActionResult> PutStorage(Guid id, ShopitemViewModel storage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != storage.Id)
            {
                return(BadRequest());
            }
            storage.Id = id;
            try
            {
                await _shopitemRepository.EditAsync(storage.ToModel());
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!StorageExist(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
예제 #2
0
        private void MButtonAdd_Click(object sender, EventArgs e)
        {
            mProgressBar.Visibility = Android.Views.ViewStates.Visible;
            ShopitemViewModel newShopList = new ShopitemViewModel()
            {
                ItemName    = Name.Text,
                Quantity    = int.Parse(Quantity.Text),
                ShoplistId  = ShopListFragment.mSelectedShopList.Id,
                AddedUserId = LoginPageActivity.StaticUserClass.ID.ToString()
            };

            new Thread(new ThreadStart(async delegate
            {
                UpgradeProgress();
                var isAdded = mShopItemDataService.Add(newShopList.ToModel());

                if (isAdded)
                {
                    LoginPageActivity.mGlobalShopItem = await mShopItemDataService.GetAll();
                    this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "ShopList Added", ToastLength.Long).Show());
                    mProgressBar.Visibility = Android.Views.ViewStates.Invisible;
                    ReplaceFragment(new ShopItemsFragment(), "Manage ShopLists");
                }
                else
                {
                    this.Activity.RunOnUiThread(() => Toast.MakeText(this.Activity, "Failed", ToastLength.Long).Show());
                }
            })).Start();
        }
예제 #3
0
        public IHttpActionResult PostStorage(ShopitemViewModel storage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                _shopitemRepository.Add(storage.ToModel());
            }
            catch (DbUpdateException)
            {
                if (StorageExist(storage.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = storage.Id }, storage));
        }