コード例 #1
0
        public async Task <IActionResult> Index()
        {
            var listOperation = await _bo.ListNotDeletedAsync();

            if (!listOperation.Success)
            {
                return(OperationErrorBackToIndex(listOperation.Exception));
            }

            var lst = new List <ReservedQueueViewModel>();

            foreach (var item in listOperation.Result)
            {
                var limitCheck = await _bo.TwoHourLimitReserveAsync(item.Id);

                if (limitCheck.Result && limitCheck.Success)
                {
                    lst.Add(ReservedQueueViewModel.Parse(item));
                }
            }

            var listEOperation = await _ebo.ListNotDeletedAsync();

            if (!listOperation.Success)
            {
                return(OperationErrorBackToIndex(listOperation.Exception));
            }

            var elst = new List <EstablishmentViewModel>();

            foreach (var item in listEOperation.Result)
            {
                elst.Add(EstablishmentViewModel.Parse(item));
            }

            var estList = await GetEstablishmentViewModels(listOperation.Result.Select(x => x.EstablishmentId).Distinct().ToList());

            var profiList = await GetProfileViewModels(listOperation.Result.Select(x => x.ProfileId).Distinct().ToList());

            var cList = await GetCompanyViewModels(listEOperation.Result.Select(x => x.CompanyId).Distinct().ToList());

            ViewData["Companies"]      = cList;
            ViewData["Establishments"] = estList;
            ViewData["Profiles"]       = profiList;
            ViewData["Title"]          = "Reserved Queues";
            ViewData["BreadCrumbs"]    = GetCrumbs();
            ViewData["DeleteHref"]     = GetDeleteRef();

            return(View(lst));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(Guid id, ReservedQueueViewModel 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);

                        getOperation = await _bo.ReadAsync((Guid)id);

                        if (!getOperation.Success)
                        {
                            return(OperationErrorBackToIndex(getOperation.Exception));
                        }
                        if (getOperation.Result == null)
                        {
                            return(RecordNotFound());
                        }

                        vm = ReservedQueueViewModel.Parse(getOperation.Result);
                        Draw("Edit", "fa-edit");

                        return(View(vm));
                    }
                    if (!updateOperation.Result)
                    {
                        TempData["Alert"] = AlertFactory.GenerateAlert(NotificationType.Danger, updateOperation.Message);
                        getOperation      = await _bo.ReadAsync((Guid)id);

                        if (!getOperation.Success)
                        {
                            return(OperationErrorBackToIndex(getOperation.Exception));
                        }
                        if (getOperation.Result == null)
                        {
                            return(RecordNotFound());
                        }

                        vm = ReservedQueueViewModel.Parse(getOperation.Result);
                        Draw("Edit", "fa-edit");
                        return(View(vm));
                    }
                    else
                    {
                        return(OperationSuccess("The record was successfuly updated"));
                    }
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(Guid?id)
        {
            if (id == null)
            {
                return(RecordNotFound());
            }

            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }
            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = ReservedQueueViewModel.Parse(getOperation.Result);
            var listEstOperation = await _ebo.ListNotDeletedAsync();

            if (!listEstOperation.Success)
            {
                return(OperationErrorBackToIndex(listEstOperation.Exception));
            }

            var listProOperation = await _pbo.ListNotDeletedAsync();

            if (!listProOperation.Success)
            {
                return(OperationErrorBackToIndex(listEstOperation.Exception));
            }

            var estList = new List <SelectListItem>();

            foreach (var item in listEstOperation.Result)
            {
                var listItem = new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = item.Address
                };
                if (item.Id == vm.EstablishmentId)
                {
                    listItem.Selected = true;
                }
                estList.Add(listItem);
            }

            var profiList = new List <SelectListItem>();

            foreach (var item in listProOperation.Result)
            {
                var listItem = new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = item.VatNumber.ToString()
                };
                if (item.Id == vm.ProfileId)
                {
                    listItem.Selected = true;
                }
                profiList.Add(listItem);
            }

            ViewBag.Establishments = estList;
            ViewBag.Profiles       = profiList;
            Draw("Edit", "fa-edit");
            return(View(vm));
        }
コード例 #4
0
        public async Task <IActionResult> Details(Guid?id)
        {
            if (id == null)
            {
                return(RecordNotFound());
            }
            var getOperation = await _bo.ReadAsync((Guid)id);

            if (!getOperation.Success)
            {
                return(OperationErrorBackToIndex(getOperation.Exception));
            }
            if (getOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getEstOperation = await _ebo.ReadAsync(getOperation.Result.EstablishmentId);

            if (!getEstOperation.Success)
            {
                return(OperationErrorBackToIndex(getEstOperation.Exception));
            }
            if (getEstOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getProOperation = await _pbo.ReadAsync(getOperation.Result.ProfileId);

            if (!getProOperation.Success)
            {
                return(OperationErrorBackToIndex(getProOperation.Exception));
            }
            if (getProOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getEOperation = await _ebo.ReadAsync(getOperation.Result.EstablishmentId);

            if (!getEOperation.Success)
            {
                return(OperationErrorBackToIndex(getEOperation.Exception));
            }
            if (getEOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var getCOperation = await _cbo.ReadAsync(getEOperation.Result.CompanyId);

            if (!getCOperation.Success)
            {
                return(OperationErrorBackToIndex(getCOperation.Exception));
            }
            if (getCOperation.Result == null)
            {
                return(RecordNotFound());
            }

            var vm = ReservedQueueViewModel.Parse(getOperation.Result);

            Draw("Details", "fa-search");
            ViewData["Company"]       = CompanyViewModel.Parse(getCOperation.Result);
            ViewData["Establishment"] = EstablishmentViewModel.Parse(getEstOperation.Result);
            ViewData["Profile"]       = ProfileViewModel.Parse(getProOperation.Result);
            return(View(vm));
        }