public async Task <BazaarListItem> UpdateAsync(UpdateBazaarListItem input)
        {
            var willUpdate = await GetAsync(input.Id);

            willUpdate.IsCanceled  = input.IsCanceled;
            willUpdate.IsCompleted = input.IsCompleted;
            willUpdate.Name        = input.Name;
            _context.BazaarListItems.Update(willUpdate);
            await _context.SaveChangesAsync();

            return(willUpdate);
        }
        public async Task <IActionResult> Update(int id)
        {
            var existItem = await _bazaarListItemService.GetAsync(id);

            UpdateBazaarListItem model = new UpdateBazaarListItem
            {
                Id            = existItem.Id,
                BazaarListId  = existItem.BazaarListId,
                CreatorUserId = existItem.CreatorUserId,
                IsCanceled    = existItem.IsCanceled,
                IsCompleted   = existItem.IsCompleted,
                Name          = existItem.Name
            };

            return(View(model));
        }
        public async Task <IActionResult> Update(UpdateBazaarListItem model)
        {
            if (ModelState.IsValid)
            {
                var updated = await _bazaarListItemService.UpdateAsync(model);

                UpdateBazaarListItem newModel = new UpdateBazaarListItem
                {
                    Id            = updated.Id,
                    BazaarListId  = updated.BazaarListId,
                    CreatorUserId = updated.CreatorUserId,
                    IsCanceled    = updated.IsCanceled,
                    IsCompleted   = updated.IsCompleted
                };
                return(View(newModel));
            }
            return(View(model));
        }
예제 #4
0
 public async Task <BazaarListItem> UpdateAsync(UpdateBazaarListItem input)
 {
     return(await _bazaarListItemService.UpdateAsync(input));
 }