public ActionResult Index() { #if DEBUG ViewBag.Debug = "true"; #else ViewBag.Debug = null; #endif //ViewBag.InventoryItems = db.InventoryItem.ToList(); //var roomL = db.Room.ToList().OrderBy(r => r.RoomID); @ViewBag.Title = "Old City Movers Estimate | A Philadelphia, PA insured & bonded moving company"; @ViewBag.Description = "Use Old City Mover's Estimate Form to plan your move"; @ViewBag.Keywords = "Moving company, movers, residential, home, storage, warehouse, commercial, furniture, Philadelphia movers, New York movers, Delaware movers, New Jersey Movers"; // ViewBag.InventoryItems = db.InventoryItem.Include("Room").ToList().OrderBy(x => x.inventoryItem); //ViewBag.roomList = db.Room.ToList().OrderBy(r => r.RoomID); //ViewBag.inventoryCount = db.InventoryItem.Count(); OCMovers_MC4.ViewModel.EstimateForm estimateForm = new OCMovers_MC4.ViewModel.EstimateForm(); //return View(db.InventoryItems.ToList()); return(View(estimateForm)); }
// Application uses Welcome method above. This is a duplicate // Customer Copy //public virtual MvcMailMessage CustomerCopyEstimateForm(EstimateForm estimateForm, List<EstimateFormInventory> model) public virtual MvcMailMessage CustomerCopyEstimateForm(EstimateForm estimateForm) { ViewData["estimateForm"] = estimateForm; //ViewBag.EstimateFormInventory = model; var isFlex = @estimateForm.IsDateFlexible ? "*" : ""; var month = @estimateForm.moveDateEnd.ToString("MMM"); var day = @estimateForm.moveDateEnd.ToString("dd"); var moveDate = string.Concat(month, " ", day, isFlex); return(Populate(x => { x.Subject = "Old City Movers Estimate Form Received: " + estimateForm.name.ToUpper() + " ( " + moveDate + " )"; x.ViewName = "CustomerCopyEstimateForm"; x.To.Add(new MailAddress(estimateForm.email, displayName: estimateForm.name.ToUpper())); x.Bcc.Add(new MailAddress(ConfigurationManager.AppSettings["EstimateEmail"])); x.Bcc.Add(new MailAddress(ConfigurationManager.AppSettings["EricBCCEmail"])); x.From = new MailAddress(estimateForm.email, displayName: estimateForm.name.ToUpper()); x.Sender = new MailAddress(estimateForm.email, displayName: estimateForm.name.ToUpper()); x.IsBodyHtml = true; })); }
public JsonResult SendEstimate(OCMovers_MC4.ViewModel.EstimateForm estimateForm, List <Address> addresses, List <EstimateFormInventory> model = null) { Console.WriteLine(addresses); try { if (ModelState.IsValid) { Guid EG = Guid.NewGuid(); estimateForm.EstimateGuid = EG; OCMovers_MC4.Models.EstimateForm newEstimate = new OCMovers_MC4.Models.EstimateForm() { EstimateGuid = EG, Feedback = estimateForm.Feedback, InventoryWriteIn = estimateForm.InventoryWriteIn, InventoryItem = estimateForm.InventoryItem, IsDateFlexible = estimateForm.IsDateFlexible, PreviousCustomer = estimateForm.PreviousCustomer, PreviousCustomerName = estimateForm.PreviousCustomerName, agreeCorrect = estimateForm.agreeCorrect, email = estimateForm.email, estBoxCount = estimateForm.estBoxCount, moveDateEnd = estimateForm.moveDateEnd, moveDescription = estimateForm.moveDescription, name = estimateForm.name, packingServices = estimateForm.packingServices, phone = estimateForm.phone, //old fields not required here dwellingTypeCurrent = estimateForm.dwellingTypeCurrent, dwellingTypeCurrentFloorApt = estimateForm.dwellingTypeCurrentFloorApt, dwellingTypeCurrentFloorHouse = estimateForm.dwellingTypeCurrentFloorHouse, dwellingTypeDestination = estimateForm.dwellingTypeDestination, dwellingTypeDestinationFloorApt = estimateForm.dwellingTypeDestinationFloorApt, dwellingTypeDestinationFloorHouse = estimateForm.dwellingTypeDestinationFloorHouse, loc1BuildingName = estimateForm.loc1BuildingName, loc1Address1 = estimateForm.loc1Address1, loc1Address2 = estimateForm.loc1Address2, loc1Apartment = estimateForm.loc1Apartment, loc1City = estimateForm.loc1City, loc1State = estimateForm.loc1State, loc1Postal = estimateForm.loc1Postal, loc2BuildingName = estimateForm.loc2BuildingName, loc2Address1 = estimateForm.loc2Address1, loc2Address2 = estimateForm.loc2Address2, loc2Apartment = estimateForm.loc2Apartment, loc2City = estimateForm.loc2City, loc2State = estimateForm.loc2State, loc2Postal = estimateForm.loc2Postal, elevStairsCurrent = estimateForm.elevStairsCurrent, elevStairsDestination = estimateForm.elevStairsDestination, elevStairsResExp = estimateForm.elevStairsResExp, stairsToFrontExp = estimateForm.stairsToFrontExp, longWalksToDoorExp = estimateForm.longWalksToDoorExp, specialCareItemExp = estimateForm.specialCareItemExp, //Addresses = new List<Address>(), elevStairsRes = estimateForm.elevStairsRes, longWalksToDoor = estimateForm.longWalksToDoor, numRoomsCurrent = estimateForm.numRoomsCurrent, numRoomsDestination = estimateForm.numRoomsDestination, specialCareItem = estimateForm.specialCareItem, stairsToFront = estimateForm.stairsToFront, submitDate = DateTime.Now, StorageGroundFloorAccessCurrent = estimateForm.StorageGroundFloorAccessCurrent, StorageGroundFloorAccessDestination = estimateForm.StorageGroundFloorAccessDestination, StorageTypeCurrent = estimateForm.StorageTypeCurrent, StorageTypeDestination = estimateForm.StorageTypeDestination, OtherCurrent = estimateForm.OtherCurrent, OtherDestination = estimateForm.OtherDestination }; db.EstimateForm.Add(newEstimate); db.SaveChanges(); //foreach (var a in addresses) //{ // var newAddress = new CustomerAddress() // { // AddressType = a.AddressType, // Address1 = a.Address1, // AptNum = a.AptNum, // BuildingName = a.BuildingName, // City = a.City, // EstimateId = newEstimate.EstimateFormID, // Postcode = a.Postcode, // State = a.State, // AptFloor = a.AptFloor ?? 0, // ElevatorStairs = a.ElevatorStairs, // ElevatorStairsDescription = a.ElevatorStairsDescription, // HouseOrApt = a.HouseOrApt, // HouseStories = a.HouseStories, // Inventory = a.Inventory, // LongWalks = a.LongWalks, // LongWalksDescription = a.LongWalksDescription, // Notes = a.Notes, // NumberOfBedrooms = a.NumberOfBedrooms, // SpecialCare = a.SpecialCare, // SpecialCareDescription = a.SpecialCareDescription, // Stairs = a.Stairs, // StairsDescription = a.StairsDescription, // BoxCount = a.BoxCount // }; // db.CustomerAddress.Add(newAddress); // db.SaveChanges(); //} //newEstimate.Addresses = addresses; UserMailer.Welcome(newEstimate).Send(); return(new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { result = "success" } }); } else { var es = ModelState.Where(x => x.Value.Errors.Count > 0) .Select(x => new { x.Key, x.Value.Errors }) .ToArray(); var errors = ModelState .Where(x => x.Value.Errors.Count > 0) .Select(x => new { x.Key, x.Value.Errors }) .ToArray(); Debug.WriteLine("Model state not valid"); StringBuilder sb = new StringBuilder(); foreach (var c in errors) { sb.Append(string.Concat(c.Key, ": ", c.Errors[0].ErrorMessage, "<br>")); } string output = sb.ToString(); CreateErrorLogEmail(output, null); UserMailer.SendModelStateError(output).Send(); return(new JsonResult() { JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new { result = output } }); ; } } catch (Exception ex) { var str = new JavaScriptSerializer().Serialize(estimateForm); CreateErrorLogEmail(str, ex); throw; } }