public ActionResult EditContactAdditional(int contactAdditionalId) { 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 { ContactAdditionalModel model = new ContactAdditionalModel(); model = dataService.GenerateContactAdditionalModelById(1); return(View(model)); //string id = (string)Request.Form["id"]; //if (ModelState.IsValid) //{ // dataService.UpdateContactAdditional(int.Parse(id), "", model.ContactAdditionalModel.ContactDescription); // return RedirectToAction("Edit", "Contact"); //} //else //{ // model = new ContactViewModel(); // model.ContactAdditionalModel = new Models.ContactAdditionalModel(); // model.ContactAdditionalModel.ContactAdditionalId = int.Parse(id); // model.ContactAdditionalModel.ContactDescription = model.ContactAdditionalModel.ContactDescription; // return View(model.ContactAdditionalModel); //} } catch (Exception ex) { throw ex; } finally { dataService = null; } }
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; } }