public ActionResult SaveContactData(FormCollection collection) { #region Util function // utility function Func<FormCollection, string> __getInterests = c => { return string.Join(",", posList.Where(q => c[q.OptionName] != null).Select(a => a.Value).ToArray<object>()); // NOTE: casted as object array to eliminate method abiguity }; #endregion var info = new ContactInfo(); // scrape form data info.FullName = collection["name"]; info.EmailAddress = collection["email"]; info.PhoneNumber = collection["phone"]; info.Major = collection["major"]; info.About = collection["about"]; info.PreferredContactMethod = collection["contact-pref"]; info.Interests = __getInterests(collection); info.LastUpdated = DateTime.Now; info.RequesterID = collection["requesterid"]; info.GradYear = collection["gradyear"]; info.JobType = collection["jobtype"]; if (Session["_ActiveSchool"] != null) { var data = (SchoolData)Session["_ActiveSchool"]; info.School = data.Alias; } if (Request.Files.Count > 0) { var file = Request.Files[0]; if (!string.IsNullOrWhiteSpace(file.FileName)) { info.UploadKey = string.Format("{0}-{1:yyyyMMddHHmmss}{2}", info.RequesterID, DateTime.Now, Path.GetExtension(file.FileName)); repo.SaveAttachment(info.UploadKey, file.InputStream); } } var mm = new MailManager(); mm.NotifySave(info); // add cookies Response.Cookies[CookieNames.LastUpdated].Value = info.LastUpdated.ToString(); Response.Cookies[CookieNames.FullName].Value = info.FullName; Response.Cookies[CookieNames.EmailAddress].Value = info.EmailAddress; Response.Cookies[CookieNames.Phone].Value = info.PhoneNumber; Response.Cookies[CookieNames.Major].Value = info.Major; Response.Cookies[CookieNames.About].Value = info.About; Response.Cookies[CookieNames.Interests].Value = info.Interests; Response.Cookies[CookieNames.PreferredContactMethod].Value = info.PreferredContactMethod; Response.Cookies[CookieNames.RequesterID].Value = info.RequesterID; Response.Cookies[CookieNames.GradYear].Value = info.GradYear; Response.Cookies[CookieNames.JobType].Value = info.JobType; CookieNames.SetResponseLifetime(Response, 365); // in days // save contact info repo.SaveContact(info); HttpContext.Cache.Add("Saved", true, null, DateTime.Now.AddSeconds(15), Cache.NoSlidingExpiration, CacheItemPriority.Default, null); return RedirectToAction("Index"); }