public ContactAdditionalModel GenerateContactAdditionalModelById(int id)
        {
            try
            {

                ContactAdditionalModel model = new ContactAdditionalModel();
                using (VenturadaDataContext vdc = new VenturadaDataContext())
                {

                    var table = from p in vdc.ContactAdditionals.ToList()
                                where p.ContactAdditionalId == id
                                select p;

                    model = new ContactAdditionalModel();
                    model.ContactAdditionalId = table.FirstOrDefault().ContactAdditionalId;
                    model.ContactTitle = table.FirstOrDefault().ContactTitle;
                    model.ContactDescription = table.FirstOrDefault().ContactDescription;
                    return model;
                }

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Example #2
0
        public ActionResult EditContactAdditional(ContactAdditionalModel model)
        {
            CommonDataService cds = new CommonDataService();

            CommonModel cm = new CommonModel();

            cm = cds.GenerateCommonModel();
            Session["FaceBook"] = cm.FaceBook;
            Session["Twitter"] = cm.Twitter;
            Session["Youtube"] = cm.Youtube;
            Session["Instagram"] = cm.Instagram;
            Session["PhoneNumber"] = cm.PhoneNumber;
            Session["Email"] = cm.Email;
            Session["ShoppingHours"] = cm.ShoppingHours;
            ContactDataService dataService = new ContactDataService();
            try
            {
                string id = (string)Request.Form["id"];

                if (ModelState.IsValid)
                {
                    dataService.UpdateContactAdditional(int.Parse(id), "", model.ContactDescription);

                    return RedirectToAction("Edit", "Contact");
                }
                else
                {

                    model = new ContactAdditionalModel();
                    model.ContactAdditionalId = int.Parse(id);
                    model.ContactDescription = model.ContactDescription;
                    return View(model);
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                dataService = null;

            }
        }