예제 #1
0
        public ActionResult CreateSupportLinks(SupportLinks form)
        {
            ActionResult response;

            try
            {
                // checking to see if valid
                if (ModelState.IsValid)
                {
                    // checking for http
                    if (!form.Url.StartsWith("https://"))
                    {
                        // adding http
                        form.Url = "https://" + form.Url;
                    }

                    // creating dataobject
                    SupportLinksDO dataObject = new SupportLinksDO()
                    {
                        //paramaters for support links
                        SupportId = form.SupportId,
                        Name      = form.Name,
                        Address   = form.Address,
                        Phone     = form.Phone,
                        Url       = form.Url,
                        UserId    = (long)Session["UserId"]
                    };
                    // display param info
                    SupportLinksDataAccess.CreateSupportLinks(dataObject);


                    TempData["SupportId"] = dataObject.SupportId;
                    response = RedirectToAction("AllSupportLinks", "SupportLinks");
                }
                else
                {
                    response = View(form);
                }
            }
            catch (SqlException Sqlex)
            {
                //Log exception for sql
                logger.ErrorLogger(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, Sqlex);
                response            = View(form);
                TempData["Message"] = "Connection Error";
            }
            catch (Exception ex)
            {
                // log exception for other exceptions
                logger.ErrorLogger(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex);
                response            = View(form);
                TempData["Message"] = "Error Try Again";
            }
            return(response);
        }
예제 #2
0
        /// <summary>
        ///  mapping the PO to DO
        /// </summary>
        /// <param name="from"></param>
        /// <returns> send it out</returns>
        public SupportLinksDO MapPoToDo(SupportLinks from)
        {
            SupportLinksDO to = new SupportLinksDO();

            to.SupportId = from.SupportId;
            to.Name      = from.Name;
            to.Address   = from.Address;
            to.Phone     = from.Phone;
            to.Url       = from.Url;
            to.UserId    = from.UserId;

            return(to);
        }
예제 #3
0
        /// <summary>
        /// DO to PO
        /// </summary>
        /// <param name="from"></param>
        /// <returns> sends information out</returns>
        public SupportLinks MapDoToPo(SupportLinksDO from)
        {
            SupportLinks to = new SupportLinks();

            to.SupportId = from.SupportId;
            to.Name      = from.Name;
            to.Address   = from.Address;
            to.Phone     = from.Phone;
            to.Url       = from.Url;
            to.UserId    = from.UserId;

            return(to);
        }
예제 #4
0
        public ActionResult DeleteSupportLinks(long supportId)
        {
            ActionResult response;

            // creating variables and mapping
            SupportLinksDO supportLinks       = SupportLinksDataAccess.ViewSupportLinksById(supportId);
            SupportLinks   deleteSupportLinks = mapper.MapDoToPo(supportLinks);
            long           supportID          = deleteSupportLinks.SupportId;


            try
            {
                //check to see if id is valid
                if (supportId > 0)
                {
                    // if valid
                    SupportLinksDataAccess.DeleteSupportLinks(supportId);
                    response = RedirectToAction("AllSupportLinks", "SupportLinks");
                }
                else
                {
                    // if not valid
                    response = RedirectToAction("AllSupportLinks", "SupportLinks");
                }
            }
            catch (SqlException Sqlex)
            {
                //Log exception for sql
                logger.ErrorLogger(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, Sqlex);
                response            = View(supportLinks);
                TempData["Message"] = "Connection Error";
            }
            catch (Exception ex)
            {
                // log exception for other exceptions
                logger.ErrorLogger(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex);
                response            = View(supportLinks);
                TempData["Message"] = "Error Try Again";
            }
            return(response);
        }
예제 #5
0
        public ActionResult UpdateSupportLinks(SupportLinks form)
        {
            ActionResult response;

            try
            {
                // checking to see if valid
                if (ModelState.IsValid)
                {
                    // mapping
                    SupportLinksDO supportLinksDO = mapper.MapPoToDo(form);
                    SupportLinksDataAccess.UpdateSupportLinks(supportLinksDO);

                    // redirect
                    response = RedirectToAction("AllSupportLinks", "SupportLinks");
                }
                else
                {
                    // if not valid
                    response = View(form);
                }
            }
            catch (SqlException Sqlex)
            {
                //Log exception for sql
                logger.ErrorLogger(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, Sqlex);
                response            = View(form);
                TempData["Message"] = "Connection Error";
            }
            catch (Exception ex)
            {
                // log exception for other exceptions
                logger.ErrorLogger(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex);
                response            = View(form);
                TempData["Message"] = "Error Try Again";
            }
            return(response);
        }