public async Task <IActionResult> Edit(Guid id, StoreQueueViewModel vm)
        {
            if (ModelState.IsValid)
            {
                var getOperation = await _bo.ReadAsync(id);

                if (!getOperation.Success)
                {
                    return(OperationErrorBackToIndex(getOperation.Exception));
                }
                if (getOperation.Result == null)
                {
                    return(RecordNotFound());
                }
                var result = getOperation.Result;
                if (!vm.CompareToModel(result))
                {
                    result = vm.ToModel(result);
                    var updateOperation = await _bo.UpdateAsync(result);

                    if (!updateOperation.Success)
                    {
                        TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Exception);
                        Draw("Edit", "fa-edit");
                        return(View(vm));
                    }
                    else
                    {
                        return(OperationSuccess("The record was successfuly updated"));
                    }
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 2
0
        public void TestUpdateStoreQueuesAsync()
        {
            ContextSeeder.Seed();
            var bo         = new StoreQueueBusinessObject();
            var resultList = bo.List();
            var item       = resultList.Result.FirstOrDefault();

            item.Quantity = 24;
            var resUpdate  = bo.UpdateAsync(item).Result;
            var resNotList = bo.List().Result.Where(x => !x.IsDeleted);

            Assert.IsTrue(resUpdate.Success && resNotList.First().Quantity == 24);
        }
Exemplo n.º 3
0
        public void TestUpdateStoreQueueAsync()
        {
            ContextSeeder.Seed();
            var bo       = new StoreQueueBusinessObject();
            var stoQList = bo.ListAsync().Result;
            var item     = stoQList.Result.FirstOrDefault();

            item.Quantity = 11;
            var stoQUpdate = bo.UpdateAsync(item).Result;

            stoQList = bo.ListNotDeletedAsync().Result;
            Assert.IsTrue(stoQList.Success && stoQUpdate.Success && stoQList.Result.First().Quantity == 11);
        }