Пример #1
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 = CommentVM.Parse(getOperation.Result);

            var listClientOperation = await _clientBO.ListUndeletedAsync();

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

            var clientList = new List <SelectListItem>();

            foreach (var item in listClientOperation.Result)
            {
                var clientName = await _profileBO.ReadAsync(item.ProfileId);

                var listItem = new SelectListItem()
                {
                    Value = item.Id.ToString(), Text = (clientName.Result.FullName + " -- " + clientName.Result.Country)
                };

                if (item.Id == vm.ClientId)
                {
                    listItem.Selected = true;
                }

                clientList.Add(listItem);
            }

            ViewBag.Clients = clientList;

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "Edit", Controller = "Comments", Icon = "fa-edit", Text = "Edit"
            });

            ViewData["Title"]       = "Edit comment";
            ViewData["BreadCrumbs"] = crumbs;
            return(View(vm));
        }
Пример #2
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 getClientOperation = await _clientBO.ReadAsync(getOperation.Result.ClientId);

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

            if (getClientOperation.Result == null)
            {
                return(RecordNotFound());
            }

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

            var crumbs = GetCrumbs();

            crumbs.Add(new BreadCrumb()
            {
                Action = "Details", Controller = "Comments", Icon = "fa-info-circle", Text = "Details"
            });

            ViewData["Title"]       = "Comment details";
            ViewData["BreadCrumbs"] = crumbs;
            ViewData["Client"]      = ClientVM.Parse(getClientOperation.Result);
            return(View(vm));
        }
Пример #3
0
        public async Task <IActionResult> Index()
        {
            var listOperation = await _bo.ListUndeletedAsync();

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

            var finalList = new List <CommentVM>();

            foreach (var item in listOperation.Result)
            {
                finalList.Add(CommentVM.Parse(item));
            }

            var clientList = await GetClientViewModels(listOperation.Result.Select(x => x.ClientId).Distinct().ToList());

            ViewData["Title"]       = "Comments";
            ViewData["Clients"]     = clientList;
            ViewData["BreadCrumbs"] = GetCrumbs();
            ViewData["DeleteHref"]  = GetDeleteRef();
            return(View(finalList));
        }