Example #1
0
        public ActionResult DeleteClassificationPost(int id)
        {
            AuthorizeAndRedirect();
            ClassificationValidation validation = _Manager.DeleteClassification(_Manager.GetClassificationFromID(id));

            if (validation.IsValid)
            {
                return(RedirectToAction("BrowseAllBooks", "Book", null));
            }
            ValidationMessages.ConvertCodeToMsg(ModelState, validation.ErrorDict);
            return(View("DeleteClassification", _Manager.GetClassificationFromID(id)));
        }
Example #2
0
        public ActionResult CreateClassification(Classification classification)
        {
            AuthorizeAndRedirect();
            ClassificationValidation validation = _Manager.CreateClassification(classification);

            if (!validation.IsValid)
            {
                ValidationMessages.ConvertCodeToMsg(ModelState, validation.ErrorDict);
                return(RedirectToAction("CreateClassification"));
            }
            ModelState.Clear();
            return(RedirectToAction("BrowseAllBooks", "Book", null));
        }
Example #3
0
        public ClassificationValidation CreateClassification(Classification classification)
        {
            ClassificationValidation validation = new ClassificationValidation(classification);

            if (validation.IsValid)
            {
                if (!_Repo.CreateClassification(Mapper.Map <Classification, CLASSIFICATION>(classification)))
                {
                    validation.FailedToCreateClassification(nameof(classification.Signum));
                }
            }
            return(validation);
        }
Example #4
0
        public ClassificationValidation EditClassification(Classification classification)
        {
            ClassificationValidation validation = new ClassificationValidation(classification);

            if (validation.IsValid)
            {
                if (!_Repo.EditClassification(Mapper.Map <Classification, CLASSIFICATION>(classification)))
                {
                    validation.DoesNotExistOnServer(nameof(classification.Signum));
                }
            }
            return(validation);
        }
Example #5
0
        public ClassificationValidation DeleteClassification(Classification classification)
        {
            ClassificationValidation validation = new ClassificationValidation(classification);

            if (_Repo.DoesClassificationContainBooks(Mapper.Map <CLASSIFICATION>(classification)))
            {
                validation.BooksExistInClassification(nameof(classification.Signum));
            }
            else if (!_Repo.DeleteClassification(Mapper.Map <Classification, CLASSIFICATION>(classification)))
            {
                validation.DoesNotExistOnServer(nameof(classification.Signum));
            }
            return(validation);
        }