Esempio n. 1
0
        public ActionResult EditWebSite(int? webSiteId, string submitButton, WebSite webSite)
        {
            try
            {
                IUnitOfWorkFactory factory = new ScheduMail.UnitsOfWork.WebSiteUnitOfWorkFactory();
                IWebSiteUnitOfWork unitOfWork = factory.GetWebSiteUnitOfWork();

                SelectList list = this.CopyToSelectList(0, unitOfWork);
                ViewData["webSites"] = this.GetWebSiteList();

                switch (submitButton)
                {
                    case "Add New Web Site":
                        // reset so displays default value                        
                        return RedirectToAction("EditWebSite", new { WebSiteId = -1 });
                    case "Save":
                        unitOfWork.Save(webSite);
                        int? tempVal = null;
                        return RedirectToAction("EditWebSite", new { WebSiteId = tempVal });
                    case "Delete":
                        webSite = unitOfWork.GetById(webSiteId.Value);
                        unitOfWork.Delete(webSite);
                        tempVal = null;
                        return RedirectToAction("EditWebSite", new { WebSiteId = tempVal });
                    default: // Change of drop down list ...                                           
                        return RedirectToAction("EditWebSite", new { WebSiteId = webSiteId });
                }
            }
            catch (RuleException ex)
            {
                ViewData["webSites"] = this.GetWebSiteList();
                ex.CopyToModelState(ModelState);
                return View();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Lists this instance.
        /// </summary>
        /// <returns>List View.</returns>
        public ActionResult List()
        {
            IUnitOfWorkFactory factory = new ScheduMail.UnitsOfWork.WebSiteUnitOfWorkFactory();
            IWebSiteUnitOfWork unitOfWork = factory.GetWebSiteUnitOfWork();            

            return View(unitOfWork.List);
        }
        /// <summary>
        /// Gets the web site list.
        /// </summary>
        /// <returns>List of Selected Items.</returns>
        private SelectList GetWebSiteList()
        {
            IUnitOfWorkFactory factory = new ScheduMail.UnitsOfWork.WebSiteUnitOfWorkFactory();
            IWebSiteUnitOfWork unitOfWork = factory.GetWebSiteUnitOfWork();

            SelectList list = this.CopyToSelectList(0, unitOfWork);
            return list;
        }
        /// <summary>
        /// Indexes the specified web site id.
        /// </summary>
        /// <param name="webSiteId">The web site id.</param>
        /// <returns>List of emails returned.</returns>
        public ActionResult Index(long? webSiteId)
        {
            IUnitOfWorkFactory factory = new ScheduMail.UnitsOfWork.WebSiteUnitOfWorkFactory();
            IWebSiteUnitOfWork unitOfWork = factory.GetWebSiteUnitOfWork();

            webSiteId = (webSiteId.HasValue == false) ? unitOfWork.List[0].Id : webSiteId;
            IList<WebSiteEMails> webSiteEmails = unitOfWork.GetWebSiteEMails(webSiteId.Value);

            ViewData["webSites"] = this.CopyToSelectList(webSiteId.Value, unitOfWork);

            return View(webSiteEmails);
        }
Esempio n. 5
0
        public ActionResult Create([Bind(Exclude = "Id")] WebSite webSite)
        {
            try
            {
                IUnitOfWorkFactory factory = new ScheduMail.UnitsOfWork.WebSiteUnitOfWorkFactory();
                IWebSiteUnitOfWork unitOfWork = factory.GetWebSiteUnitOfWork();
                unitOfWork.Save(webSite);

                return RedirectToAction("List");
            }
            catch
            {
                return View();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Edits the web site.
        /// </summary>
        /// <param name="webSiteId">The web site id.</param>
        /// <param name="submitButton">The submit button.</param>
        /// <returns>The view instance.</returns>
        public ActionResult EditWebSite(int? webSiteId, string submitButton)
        {
            IUnitOfWorkFactory factory = new ScheduMail.UnitsOfWork.WebSiteUnitOfWorkFactory();
            IWebSiteUnitOfWork unitOfWork = factory.GetWebSiteUnitOfWork();

            SelectList list = this.CopyToSelectList(0, unitOfWork);
            ViewData["webSites"] = list;

            // Deal with adding new Web Site
            if (webSiteId == -1)
            {
                return View(new WebSite { });
            }

            // if webSiteId supplied get search websites otherwise default to the first webSite.
            return View(webSiteId.HasValue ? unitOfWork.GetById(webSiteId.Value) : unitOfWork.List[0]);
        }
Esempio n. 7
0
        public ActionResult Edit(WebSite webSite)
        {
            try
            {
                IUnitOfWorkFactory factory = new ScheduMail.UnitsOfWork.WebSiteUnitOfWorkFactory();
                IWebSiteUnitOfWork unitOfWork = factory.GetWebSiteUnitOfWork();

                if (!ModelState.IsValid)
                {
                    return View();
                }

                unitOfWork.Save(webSite);
               
                return RedirectToAction("List");
            }
            catch
            {
                return View();
            }
        }
Esempio n. 8
0
 /// <summary>
 /// Edits the specified id.
 /// </summary>
 /// <param name="id">The id instance.</param>
 /// <returns>View Instance.</returns>
 public ActionResult Edit(int id)
 {
     IUnitOfWorkFactory factory = new ScheduMail.UnitsOfWork.WebSiteUnitOfWorkFactory();
     IWebSiteUnitOfWork unitOfWork = factory.GetWebSiteUnitOfWork();
     return View(unitOfWork.GetById(id));
 }