コード例 #1
0
        public ActionResult Edit(Solution Solution)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (Session["PublicImageUrl"] != null)
                    {
                        Solution.ImgUrl = Session["PublicImageUrl"].ToString();
                    }
                    SolutionsLogic.UpdateSolution(Solution);
                    Session["PublicImageUrl"] = "";
                    return(RedirectToAction("Index"));
                }
                catch (Exception e)
                {
                    LogsLogic.InsertLog(new Log()
                    {
                        Message    = e.Message,
                        StackTrace = e.StackTrace,
                        StoryName  = "MoreHolidays/Solutions/Edit(Post)",
                    });
                    Session["PublicImageUrl"] = "";

                    return(View(Solution));
                }
            }
            return(View(Solution));
        }
コード例 #2
0
        public ActionResult Create(Solution solution)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    if (Session["PublicImageUrl"] != null)
                    {
                        solution.ImgUrl = Session["PublicImageUrl"].ToString();
                    }
                    else
                    {
                        solution.ImgUrl = null;
                    }
                    SolutionsLogic.InsertNewSolution(solution);
                    Session["PublicImageUrl"] = "";
                    return(RedirectToAction("Index"));

                    // return PartialView("JavascriptRedirect", new JavascriptRedirectModel("/Home/Index"));
                }
                catch (Exception e)
                {
                    LogsLogic.InsertLog(new Log()
                    {
                        Message    = e.Message,
                        StackTrace = e.StackTrace,
                        StoryName  = "MoreHolidays/Solutions/Create(Post)"
                    });
                    Session["PublicImageUrl"] = "";
                    return(View(solution));
                    //Parameters = new JavaScriptSerializer().Serialize(project)
                }
            }
            return(View(solution));
        }
        public void ByOrganisation_CallsFilter()
        {
            var logic = new SolutionsLogic(_modifier.Object, _datastore.Object, _contacts.Object, _context.Object, _validator.Object, _filter.Object, _evidenceBlobStoreLogic.Object);

            logic.ByOrganisation("some Id");

            _filter.Verify(x => x.Filter(It.IsAny <IEnumerable <Solutions> >()), Times.Once());
        }
コード例 #4
0
        public ActionResult Index(int solutionId)
        {
            FeatureIndexModel model = new FeatureIndexModel();

            model.SolutionId   = solutionId;
            model.SolutionName = SolutionsLogic.GetSolutionById(solutionId).Name;
            return(View(model));
        }
        public void Update_Calls_Modifier()
        {
            var logic = new SolutionsLogic(_modifier.Object, _datastore.Object, _contacts.Object, _context.Object, _validator.Object, _filter.Object, _evidenceBlobStoreLogic.Object);
            var soln  = Creator.GetSolution();

            var valres = new ValidationResult();

            _validator.Setup(x => x.Validate(It.IsAny <ValidationContext>())).Returns(valres);

            logic.Update(soln);

            _modifier.Verify(x => x.ForUpdate(soln), Times.Once);
        }
        public void Update_DoesNotCallPrepareForSolution_WhenNotRegistered(SolutionStatus status)
        {
            var logic = new SolutionsLogic(_modifier.Object, _datastore.Object, _contacts.Object, _context.Object, _validator.Object, _filter.Object, _evidenceBlobStoreLogic.Object);
            var soln  = Creator.GetSolution(status: status);

            _context.Setup(x => x.HttpContext).Returns(Creator.GetContext());
            _contacts.Setup(x => x.ByEmail(It.IsAny <string>())).Returns(Creator.GetContact());

            var valres = new ValidationResult();

            _validator.Setup(x => x.Validate(It.IsAny <ValidationContext>())).Returns(valres);

            logic.Update(soln);

            _evidenceBlobStoreLogic.Verify(x => x.PrepareForSolution(soln.Id), Times.Never);
        }
コード例 #7
0
 public ActionResult Delete(int id)
 {
     try
     {
         SolutionsLogic.DeleteSolution(id);
     }
     catch (Exception e)
     {
         LogsLogic.InsertLog(new Log()
         {
             Message    = e.Message,
             StackTrace = e.StackTrace,
             StoryName  = "MoreHolidays/Solutions/Delete",
             Parameters = "id=" + id
         });
     }
     return(RedirectToAction("Index"));
 }
        public void Update_CallsValidator_WithRuleset()
        {
            var logic = new SolutionsLogic(_modifier.Object, _datastore.Object, _contacts.Object, _context.Object, _validator.Object, _filter.Object, _evidenceBlobStoreLogic.Object);
            var soln  = Creator.GetSolution();

            _context.Setup(x => x.HttpContext).Returns(Creator.GetContext());
            _contacts.Setup(x => x.ByEmail(It.IsAny <string>())).Returns(Creator.GetContact());

            var valres = new ValidationResult();

            _validator.Setup(x => x.Validate(It.IsAny <ValidationContext>())).Returns(valres);

            logic.Update(soln);

            _validator.Verify(x => x.ValidateAndThrowEx(
                                  It.Is <Solutions>(s => s == soln),
                                  It.Is <string>(rs => rs == nameof(ISolutionsLogic.Update))), Times.Once());
        }
コード例 #9
0
        public ActionResult Edit(int id)
        {
            Solution Solution = new Solution();

            try
            {
                Solution = SolutionsLogic.GetSolutionById(id);
            }
            catch (Exception e)
            {
                LogsLogic.InsertLog(new Log()
                {
                    Message    = e.Message,
                    StackTrace = e.StackTrace,
                    StoryName  = "MoreHolidays/Solutions/Edit(Get)",
                    Parameters = "id=" + id
                });
                Session["PublicImageUrl"] = "";
            }
            return(View("Edit", Solution));
        }
コード例 #10
0
        public ActionResult SolutionsList(int?pageNo)
        {
            var             page  = pageNo ?? 0;
            List <Solution> model = new List <Solution>();

            try
            {
                model = SolutionsLogic.GetSolutionsList(page);
            }
            catch (Exception e)
            {
                LogsLogic.InsertLog(new Log()
                {
                    Message    = e.Message,
                    StackTrace = e.StackTrace,
                    StoryName  = "MoreHolidays/Solutions/SolutionsList",
                    Parameters = "& pageNo=" + page
                });
            }

            return(View(model));
        }