Beispiel #1
0
        public IActionResult Index()
        {
            var result = _classifyService.Get()
                         .Select(m => ClassificationViewModel
                                 .Convert(m.Id, m.Content, m.CreationTime, m.ModificationTime));

            return(View(result));
        }
Beispiel #2
0
        public IActionResult Classifications()
        {
            ClassificationViewModel model = new ClassificationViewModel()
            {
                AllClassifications = this.dataService.GetObjects <Classification>("Name"),
                AllPokemon         = this.dataService.GetAllPokemonWithClassificationsAndIncomplete(),
            };

            return(this.View(model));
        }
        public ActionResult Index()
        {
            List <ClassificationDTO> classifications = new List <ClassificationDTO>();

            classifications.Add(new ClassificationDTO()
            {
                Challenge = new ChallengeDTO()
                {
                    Theme = "CHALLENGE!"
                }, Position = 1, ShortStory = new ShortStoryDTO()
                {
                    Title = "Short Story 1", Author = new WriterDTO()
                    {
                        Name = "Marco"
                    }
                }
            });
            classifications.Add(new ClassificationDTO()
            {
                Challenge = new ChallengeDTO()
                {
                    Theme = "CHALLENGE!"
                }, Position = 2, ShortStory = new ShortStoryDTO()
                {
                    Title = "Short Story 2", Author = new WriterDTO()
                    {
                        Name = "Fabio"
                    }
                }
            });
            classifications.Add(new ClassificationDTO()
            {
                Challenge = new ChallengeDTO()
                {
                    Theme = "CHALLENGE!"
                }, Position = 3, ShortStory = new ShortStoryDTO()
                {
                    Title = "Short Story 3", Author = new WriterDTO()
                    {
                        Name = "Gustavo"
                    }
                }
            });

            ClassificationViewModel classificationViewModel = new ClassificationViewModel();

            classificationViewModel.ChallengeTheme  = classifications[0].Challenge.Theme;
            classificationViewModel.Classifications = classifications;
            return(View(classificationViewModel));
        }
Beispiel #4
0
        private async Task CheckCPVGroupNumber(Guid tenderGuid, ClassificationViewModel lot)
        {
            var cpvList = await TenderProvider.GetTenderCPVClassifications(tenderGuid);

            var    lotCPV      = lot.Id;
            int    firstSymbol = 3;
            string lotGroup    = lotCPV.Substring(0, firstSymbol);

            bool isTrue = cpvList.All(m => m.Substring(0, firstSymbol) == lotGroup);

            if (!isTrue)
            {
                string currentCPV = cpvList.FirstOrDefault().Substring(0, firstSymbol);
                ModelState.AddModelError("Classification.Id", $"Перші 3-и символи класифікатору повинні співпадати для всіх закупівель. Оберіть код який починається на '{currentCPV}', або змініть класифікатор для всіх об'єктів тендеру.");
            }
        }
Beispiel #5
0
 public ActionResult AddClassification(ClassificationViewModel viewModel)
 {
     using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
     {
         var newClassification = new Classification
         {
             Name        = viewModel.Name,
             Description = viewModel.Description
         };
         //try to insert and log activity
         var createStatus = _classificationService.CreateClassification(LoggedOnReadOnlyUser, newClassification);
         if (createStatus != ClassificationCreateStatus.Success)
         {
             //possibly log error here or service level.  FAILED
             TempData[AppConstants.MessageViewBagName] = new AdminGenericMessageViewModel
             {
                 Message     = _classificationService.ErrorCodeToString(createStatus),
                 MessageType = GenericMessages.danger
             };
         }
         else
         {
             try
             {
                 unitOfWork.Commit();
                 TempData[AppConstants.MessageViewBagName] = new AdminGenericMessageViewModel
                 {
                     Message     = "Classification successfully added.",
                     MessageType = GenericMessages.success
                 };
             }
             catch (Exception ex)
             {
                 unitOfWork.Rollback();
                 LoggingService.Error(ex);
                 TempData[AppConstants.MessageViewBagName] = new AdminGenericMessageViewModel
                 {
                     Message     = "Classification was not successfully added.",
                     MessageType = GenericMessages.danger
                 };
             }
         }
         return(RedirectToAction("Classification", "AdminClassification"));
     }
 }
Beispiel #6
0
        public ActionResult EditClassification(Guid id)
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                var classification     = _classificationService.GetById(id);
                var classificationList = _classificationService.GetAllClassifications();
                var listViewModel      = new ClassificationListViewModel
                {
                    NonPagedClassifications = classificationList.ToList()
                };

                var viewModel = new ClassificationViewModel
                {
                    ClassificationId = classification.Id,
                    EditName         = classification.Name,
                    EditDescription  = classification.Description,
                    _listViewModel   = listViewModel
                };
                return(View(viewModel));
            }
        }
Beispiel #7
0
        public ActionResult Classification(int?p, string search)
        {
            using (UnitOfWorkManager.NewUnitOfWork())
            {
                var pageIndex = p ?? 1;

                var allClassifications = string.IsNullOrEmpty(search) ? _classificationService.GetAll(pageIndex, SiteConstants.Instance.AdminListPageSize) :
                                         _classificationService.Search(search, pageIndex, SiteConstants.Instance.AdminListPageSize);

                var listViewModel = new ClassificationListViewModel
                {
                    Classifications = allClassifications,
                    PageIndex       = pageIndex,
                    TotalCount      = allClassifications.TotalCount,
                    Search          = search,
                    TotalPages      = allClassifications.TotalPages
                };
                var viewModel = new ClassificationViewModel
                {
                    _listViewModel = listViewModel
                };
                return(View(viewModel));
            }
        }
        public ActionResult Edit(Guid id, ClassificationViewModel classification)
        {
            try
            {
                // TODO: Add update logic here
                var item = _uow.ClassificationRepo.All.FirstOrDefault(c => c.Id == id);

                item.Name = classification.Name;
                item.Description = classification.Description;
                _uow.Save();

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Beispiel #9
0
        public ActionResult EditClassification(ClassificationViewModel viewModel)
        {
            using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork())
            {
                try
                {
                    var loggedOnUserId          = LoggedOnReadOnlyUser?.Id ?? Guid.Empty;
                    var user                    = MembershipService.Get(loggedOnUserId);
                    var classificationNameCheck = _classificationService.GetByName(viewModel.EditName);
                    var classification          = _classificationService.GetById(viewModel.ClassificationId);


                    //Updating classification name and the name is not taken
                    if (classificationNameCheck == null)
                    {
                        classification.Name        = viewModel.EditName;
                        classification.Description = viewModel.EditDescription;
                        //Fire Event
                        _classificationService.ClassificationUpdated(user, classification);
                        unitOfWork.Commit();
                        TempData[AppConstants.MessageViewBagName] = new AdminGenericMessageViewModel
                        {
                            Message     = "Classification was successfully updated.",
                            MessageType = GenericMessages.success
                        };
                        return(RedirectToAction("Classification", "AdminClassification"));
                    }
                    else
                    {
                        //Prevent updating a classification by using a name already taken.
                        //Compare UniqueKeys by names
                        if (classificationNameCheck.Id == classification.Id)
                        {
                            classification.Name        = viewModel.EditName;
                            classification.Description = viewModel.EditDescription;
                            //Fire Event
                            _classificationService.ClassificationUpdated(user, classification);
                            unitOfWork.Commit();
                            TempData[AppConstants.MessageViewBagName] = new AdminGenericMessageViewModel
                            {
                                Message     = "Classification was successfully updated.",
                                MessageType = GenericMessages.success
                            };
                            return(RedirectToAction("Classification", "AdminClassification"));
                        }
                        TempData[AppConstants.MessageViewBagName] = new AdminGenericMessageViewModel
                        {
                            Message     = "There is already a classification with the name " + viewModel.EditName + ".  Update Failed.",
                            MessageType = GenericMessages.danger
                        };
                    }
                    return(RedirectToAction("EditClassification", "AdminClassification", new { id = viewModel.ClassificationId }));
                }
                catch (Exception ex)
                {
                    unitOfWork.Rollback();
                    TempData[AppConstants.MessageViewBagName] = new AdminGenericMessageViewModel
                    {
                        Message     = "Updating the classification failed.  Error was logged for administrator.",
                        MessageType = GenericMessages.danger
                    };
                    LoggingService.Error(ex);
                }
                return(RedirectToAction("Classification", "AdminClassification"));
            }
        }