public ActionResult SetupQuestionsList() { var context = new EightHundredEntities(); var configId = GetConfigID(); var selectedQuestions = context.tbl_HVAC_ConfigQuestions.Where(item => item.ConfigID == configId).OrderBy(item => item.OrderNum).Select( item => new SetupQuestion { Id = item.QuestionID, QuestionText = item.tbl_HVAC_Questions.QuestionText }). ToList(); var allQuestions = context.tbl_HVAC_Questions.Select( item => new SetupQuestion { Id = item.QuestionID, QuestionText = item.QuestionText }).ToList(); var forChoose = allQuestions.Except(selectedQuestions, new QuestionsComparer()).ToList(); var notOrderIds = new List <int> { 35, 33, 32, 31, 22, 21, 20, 19, 17 }; var notDeleteIds = notOrderIds; return(PartialView(new SetupQuestionsModel() { QuestionsSelected = selectedQuestions, QuestionsForChoose = forChoose, NotReorderIds = notOrderIds, NotDeleteIds = notDeleteIds })); }
public ActionResult Index() { var isOwner = HttpContext.User.IsInRole("CompanyOwner"); ViewBag.Locked = isOwner; var swapBranding = false; if (HttpContext.User.IsInRole("CompanyOwner")) { var userId = _currentUser == null ? Guid.Empty : (Guid)(_currentUser.ProviderUserKey ?? Guid.Empty); using (var ctx = new MembershipConnection()) { using (var db = new EightHundredEntities()) { swapBranding = ctx.UserFranchise .Where(uf => uf.UserId == userId) .ToArray() .Select(uf => (from f in db.tbl_Franchise where f.FranchiseID == uf.FranchiseID select f).SingleOrDefault()) .Any(f => f.FranchiseTypeID == 6); } } } ViewBag.SwapBranding = swapBranding; return(View()); }
public static GuaranteeModel[] GuaranteeModels(EightHundredEntities context, int configId) { var listOfGuaranteeIds = context.tbl_HVAC_Guarantees.Select(item => item.GuaranteeID).ToList(); var listOfselectedGuarantees = context.tbl_HVAC_ConfigQuestions.Where(item => item.ConfigID == configId && listOfGuaranteeIds.Contains(item.QuestionID)).Select(i => i.QuestionID).ToArray(); var gt = context.tbl_HVAC_ConfigGuaranteeTexts.Where(item => item.ConfigID == configId).ToList(); var texts = new GuaranteeModel[listOfselectedGuarantees.Length]; for (var i = 0; i < texts.Length; ++i) { var grId = listOfselectedGuarantees[i]; var gr = context.tbl_HVAC_Guarantees.Single(item => item.GuaranteeID == grId); texts[i] = new GuaranteeModel { Id = gr.GuaranteeID, GuaranteeName = gr.GuaranteeName, GuaranteeText = "" }; if (gt.Any(item => item.GuaranteeID == gr.GuaranteeID)) { texts[i].GuaranteeText = gt.Single(item => item.GuaranteeID == gr.GuaranteeID).GuaranteeText; } } return(texts); }
private void UpdatePaymentsInJob(EightHundredEntities context, int jobId) { var payments = context.tbl_Payments.Where(item => item.JobID == jobId).ToList(); var hvacPayments = GetValue(context, jobId); foreach (var payment in payments) { if (hvacPayments.payments.All(i => i.id != payment.PaymentID)) { context.tbl_Payments.DeleteObject(payment); } } foreach (var paymentItem in hvacPayments.payments) { if (payments.All(i => i.PaymentID != paymentItem.id)) { context.tbl_Payments.AddObject(new tbl_Payments { CheckNumber = paymentItem.code, CreateDate = DateTime.Now, DepositID = 0, DepositStatus = false, DriversLicNUm = null, ErrorFlag = false, ExceptionComments = null, FranchiseID = GetFranchiseID(), JobID = jobId, PaymentAmount = decimal.Parse(paymentItem.payment, NumberStyles.Any), PaymentDate = DateTime.Now, PaymentTypeID = paymentItem.typeId }); } } context.SaveChanges(); //{"email":"","payments":[{"id":2,"type":"AmEx","payment":"$2,042.93","code":""}],"total_amount":12736.06} }
private int GetCompanyCodeID(Guid userID) { if (UserInfo != null) { if (UserInfo.UserKey == userID) { return(UserInfo.CurrentFranchise.FranchiseID); } } var context800 = new EightHundredEntities(); var useridstring = userID.ToString(); if (context800.tbl_Employee.Any(item => item.UserKey == useridstring)) { var usert = userID.ToString(); return(context800.tbl_Employee.First(item => item.UserKey == usert).FranchiseID); } var context = new MembershipEntities(); return(context.UserFranchise.Any(item => item.UserId == userID) ? context.UserFranchise.First(item => item.UserId == userID).FranchiseID : 51); //return 51; }
public virtual ActionResult LogOff() { var swapBranding = false; if (HttpContext.User.IsInRole("CompanyOwner")) { var userId = _currentUser == null ? Guid.Empty : (Guid)(_currentUser.ProviderUserKey ?? Guid.Empty); using (var ctx = new MembershipConnection()) { using (var db = new EightHundredEntities()) { swapBranding = ctx.UserFranchise .Where(uf => uf.UserId == userId) .ToArray() .Select(uf => (from f in db.tbl_Franchise where f.FranchiseID == uf.FranchiseID select f).SingleOrDefault()) .Any(f => f.FranchiseTypeID == 6); } } } authenticationService.LogOff(); SessionContainer.Remove(); if (swapBranding) { Response.Redirect("http://www.1800plumber.com"); } return(RedirectToAction("Index", "Home")); }
public Budget GetBudget(int franchiseId, DateTime asOfDate) { var month = GetKeyPerformanceIndicators(franchiseId, new DateTime(asOfDate.Year, asOfDate.Month, 1), asOfDate.Date.AddDays(1)); var today = month.GetByDay(asOfDate); var m = new Budget(franchiseId, asOfDate.Date) { DailySales = { Actual = today.ActualSales }, MonthlySales = { Actual = month.ActualSales }, DailyJobs = { Actual = today.CompletedCount }, MonthlyJobs = { Actual = month.CompletedCount }, DailyCloseRate = { Actual = today.CloseRate }, MonthlyCloseRate = { Actual = month.CloseRate }, DailyBio = { Actual = today.Bio }, MonthlyBio = { Actual = month.Bio }, DailyHomeGuard = { Actual = today.HomeGuard }, MonthlyHomeGuard = { Actual = month.HomeGuard }, DailyRecalls = { Actual = today.RecallCount }, MonthlyRecalls = { Actual = month.RecallCount }, DailyAverageTicket = { Actual = today.AverageTicket }, MonthlyAverageTicket = { Actual = month.AverageTicket } }; tbl_DailyBudget dailybudget; using (var txnCtx = new EightHundredEntities(UserKey)) { dailybudget = txnCtx.tbl_DailyBudget.SingleOrDefault(b => b.FranchiseID == franchiseId); } if (dailybudget != null) { m.DailySales.Budget = dailybudget.DailySales.GetValueOrDefault(); m.MonthlySales.Budget = dailybudget.MonthlySales.GetValueOrDefault(); m.DailyCloseRate.Budget = dailybudget.AnnualClosingRate.GetValueOrDefault(); m.MonthlyCloseRate.Budget = m.DailyCloseRate.Budget; m.DailyJobs.Budget = (decimal)dailybudget.AnnualJobs.GetValueOrDefault() / DaysPerYear; m.MonthlyJobs.Budget = (decimal)dailybudget.AnnualJobs.GetValueOrDefault() / MonthsPerYear; m.DailyAverageTicket.Budget = dailybudget.AnnualAvgTicket.GetValueOrDefault(); m.MonthlyAverageTicket.Budget = dailybudget.AnnualAvgTicket.GetValueOrDefault(); m.DailyHomeGuard.Budget = dailybudget.DailyHomeGuard.GetValueOrDefault(); m.MonthlyHomeGuard.Budget = dailybudget.MonthlyHomeGuard.GetValueOrDefault(); m.DailyBio.Budget = dailybudget.DailyBio.GetValueOrDefault(); m.MonthlyBio.Budget = dailybudget.MonthlyBio.GetValueOrDefault(); m.DailyRecalls.Budget = dailybudget.AnnualRecallPercentOfJobs.GetValueOrDefault(); m.MonthlyRecalls.Budget = dailybudget.AnnualRecallPercentOfJobs.GetValueOrDefault(); m.DailyPayroll.Budget = dailybudget.DailyPayroll.GetValueOrDefault(); m.MonthlyPayroll.Budget = dailybudget.MonthlyPayroll.GetValueOrDefault(); } return(m); }
private int GetPriceBookId(EightHundredEntities context, int frId) { var priceBook = context.tbl_HVAC_ConfigFranchise.First(item => item.FranchiseID == frId).PricebookID; var priceBookId = priceBook.HasValue ? priceBook.Value : 177; return(priceBookId); }
public ActionResult SaveGuarantee() { var configId = GetConfigID(); var context = new EightHundredEntities(); var guaranteeId = int.Parse(Request.Form["Id"]); if (context.tbl_HVAC_ConfigsApp.First(item => item.ConfigID == configId).tbl_HVAC_ConfigGuaranteeTexts.Any(item => item.GuaranteeID == guaranteeId)) { var code = context.tbl_HVAC_ConfigsApp.First(item => item.ConfigID == configId).tbl_HVAC_ConfigGuaranteeTexts.First( item => item.GuaranteeID == guaranteeId); code.GuaranteeText = Request.Form["GuaranteeText"]; } else { context.tbl_HVAC_ConfigGuaranteeTexts.AddObject(new tbl_HVAC_ConfigGuaranteeTexts { ConfigID = configId, GuaranteeID = guaranteeId, GuaranteeText = Request.Form["GuaranteeText"] }); } context.SaveChanges(); return(Json(new { result = true })); }
public ActionResult GetXmlList() { if (User.Identity.IsAuthenticated) { var configID = GetConfigID(); var jobId = GetJobCode(); var userid = GetUserID(); var context = new EightHundredEntities();//new HVAC_appContext(); if (context.tbl_HVAC_CustomersAnswers.Any(item => item.JobID == jobId && item.UserID == userid)) { return (Json( context.tbl_HVAC_CustomersAnswers.First(item => item.JobID == jobId && item.UserID == userid).tbl_HVAC_Answers.OrderBy(item => item.tbl_HVAC_Questions.tbl_HVAC_ConfigQuestions.First(d => d.ConfigID == configID && d.QuestionID == item.QuestionID).OrderNum) .Select ( item => new { id = item.QuestionID.ToString(), question = item.tbl_HVAC_Questions.QuestionText.ToString(), answer = item.Answer, data = item.Data } ).ToArray(), JsonRequestBehavior.AllowGet)); } } return(Json(new object[] { new { id = "0", question = "Approximately how old is your home?", answer = "" } }, JsonRequestBehavior.AllowGet)); }
private IEnumerable <tbl_Job> GetJobs(string userId, EightHundredEntities context) { return(context.tbl_Job.Where( item => item.tbl_Job_Status.ShowInHVACYN && item.tbl_Employee.UserKey == userId && item.ServiceID == 10).ToList()); }
public ActionResult UpdatePart(PartAdjust partdata, int pbid) { using (var db = new EightHundredEntities()) { var part = db.tbl_PB_Parts.Single(q => q.PartID == partdata.PartID); part.PartCost = partdata.PartCost.Value; part.PartStdPrice = partdata.PartStdPrice.Value; part.PartMemberPrice = partdata.PartMemberPrice.Value; part.PartAddonStdPrice = partdata.PartAddonStdPrice.Value; part.PartAddonMemberPrice = partdata.PartAddonMemberPrice.Value; var masterpart = db.tbl_PB_MasterParts.Single(q => q.MasterPartID == partdata.MasterPartID); masterpart.PartCode = partdata.PartCode; masterpart.PartName = partdata.PartDescription; db.SaveChanges(); var taskdetail = db.tbl_PB_JobCodes_Details.Where(q => q.PartID == partdata.PartID).ToList(); taskdetail.ForEach(q => q.PartCost = partdata.PartCost.Value); taskdetail.ForEach(q => q.PartStdPrice = partdata.PartStdPrice.Value); taskdetail.ForEach(q => q.PartMemberPrice = partdata.PartMemberPrice.Value); taskdetail.ForEach(q => q.PartAddonStdPrice = partdata.PartAddonStdPrice.Value); taskdetail.ForEach(q => q.PartAddonMemberPrice = partdata.PartAddonMemberPrice.Value); db.SaveChanges(); //Recalcuate Task this.treeview.RecalculatePrices(0, pbid); return(Json("success")); } }
public ActionResult GetXmlList(bool editing) { var userId = GetUserID(); if (editing) { var jobId = GetJobCode(); var context = new EightHundredEntities();//new HVAC_appContext();// var xml = ""; if (context.tbl_HVAC_CustomersAnswers.Any(item => item.JobID == jobId && item.UserID == userId)) { var customerAnswer = context.tbl_HVAC_CustomersAnswers.First(item => item.JobID == jobId && item.UserID == userId); xml = SetAnswers(context, customerAnswer); } else { var customerAnswer = new tbl_HVAC_CustomersAnswers { JobID = jobId, UserID = userId }; context.tbl_HVAC_CustomersAnswers.AddObject(customerAnswer); context.SaveChanges(); xml = SetAnswers(context, customerAnswer); } context.SaveChanges(); return(new XmlResult(xml)); } return(Json(new { result = 0 })); }
public ActionResult GetPartAdjustList(int pbid, string catid) { using (var db = new EightHundredEntities()) { var partadjustlist = (from p in db.tbl_PB_Parts join mp in db.tbl_PB_MasterParts on p.MasterPartID equals mp.MasterPartID where p.PriceBookID == pbid && mp.PartCodeID == catid select new PartAdjust { PartID = p.PartID, MasterPartID = mp.MasterPartID, PartCode = mp.PartCode, PartDescription = mp.PartName, FrequencyUsed = (from jd in db.tbl_PB_JobCodes_Details join j in db.tbl_PB_JobCodes on jd.JobCodeID equals j.JobCodeID join ss in db.tbl_PB_SubSection on j.SubSectionID equals ss.SubsectionID join s in db.tbl_PB_Section on ss.SectionID equals s.SectionID where s.PriceBookID == p.PriceBookID && jd.PartID == p.PartID select jd.Qty).Sum(), PartCost = p.PartCost, PartStdPrice = p.PartStdPrice, PartMemberPrice = p.PartMemberPrice, PartAddonStdPrice = p.PartAddonStdPrice, PartAddonMemberPrice = p.PartAddonMemberPrice }).ToList(); return(PartialView("_PartAdjustList", partadjustlist)); } }
public JsonResult SendToiPad(int id, int techId) { var pricebookName = string.Empty; var tablet = string.Empty; string folder = null; using (var db = GetContext()) { pricebookName = db.tbl_PriceBook.Single(pb => pb.PriceBookID == id).BookName; } using (var db = new EightHundredEntities()) { var result = (from t in db.tbl_Employee join tt in db.tbl_Franchise_Tablets on t.EmployeeID equals tt.EmployeeID join f in db.tbl_Franchise on t.FranchiseID equals f.FranchiseID where t.EmployeeID == techId select new { TabletNumber = tt.TabletNumber }).Single(); folder = Path.Combine(GlobalConfiguration.InitTabletDropPath, result.TabletNumber); tablet = result.TabletNumber; } using (var db = new PriceBookContext()) { db.Database.ExecuteSqlCommand("EXEC [GetXMLByPriceBook] @PriceBookId, @Folder", new System.Data.SqlClient.SqlParameter("PriceBookId", id), new System.Data.SqlClient.SqlParameter("Folder", folder)); } return(Json(new { Success = true, Name = pricebookName, Tablet = tablet })); }
public VerificationHvacData(EightHundredEntities context, int frId, int configId) { _context = context; _franchiseId = frId; _configId = configId; _listOfVerification = new List <VerificationResult>(); }
private int CreateConfigIfNotExist(int franchiseID) { var context = new EightHundredEntities(); if (context.tbl_HVAC_ConfigFranchise.Any(item => item.FranchiseID == franchiseID)) { return(context.tbl_HVAC_ConfigFranchise.First(item => item.FranchiseID == franchiseID).ConfigID); } var config = new tbl_HVAC_ConfigsApp { ConfigName = "Config for Franchise " + franchiseID.ToString() }; context.tbl_HVAC_ConfigsApp.AddObject(config); context.SaveChanges(); var configFranchise = new tbl_HVAC_ConfigFranchise { ConfigID = config.ConfigID, FranchiseID = franchiseID }; context.tbl_HVAC_ConfigFranchise.AddObject(configFranchise); SetQuestionsForNewConfig(context, config); context.SaveChanges(); return(config.ConfigID); }
public ActionResult ClearAnswers() { //TODO Verify security //var user = membershipService.GetUser(User.Identity.Name); //if (user.ProviderUserKey != null) //{ //var userID = (Guid) user.ProviderUserKey; var userId = GetUserID(); var httpCookie = Request.Cookies["id_job"]; if (httpCookie != null) { var jobID = int.Parse(httpCookie.Value.Replace("\"", "")); var context = new EightHundredEntities(); var customerAnswer = context.tbl_HVAC_CustomersAnswers.First(item => item.JobID == jobID && item.UserID == userId); foreach (var source in customerAnswer.tbl_HVAC_Answers.ToArray()) { context.tbl_HVAC_Answers.DeleteObject(source); } context.tbl_HVAC_CustomersAnswers.DeleteObject(customerAnswer); context.SaveChanges(); } //} return(Json(new { result = "success" })); }
/// <summary> /// Sends an alert to all registered recipients in a franchise for a given event. THIS FUNCTION /// SWALLOWS EXCEPTIONS. /// </summary> /// <param name="alertType">The type of alert to send.</param> /// <param name="franchiseId">The franchiseId to use when getting the list of recipients to send to.</param> /// <returns>a boolean indicating whether emails were successfully sent. Also returns true if no alerts are found.</returns> /// public bool SendAlert(AlertType alertType, int franchiseId) { try { var type = (int)alertType; var toSend = new List <MailMessage>(); using (var ctx = new EightHundredEntities(UserKey)) { var alerts = (from a in ctx.tbl_OwnerAlerts join d in ctx.tbl_OwnerAlertDestinations on a.OwnerAlertId equals d.OwnerAlertId join t in ctx.tbl_OwnerAlertCommunicationTypes on d.OwnerAlertCommunicationTypeID equals t.OwnerAlertCommunicationTypeId where a.FranchiseID == franchiseId && a.OwnerAlertTypeId == type && d.OwneralertEnabledYN && a.OwneralertEnabledYN select new { Subject = a.Subject, Body = a.Descriptions, Address = d.OwnerAlertDestinationText, Type = d.OwnerAlertCommunicationTypeID, DestText = d.OwnerAlertDestinationAdditionalText }).GroupBy(g => new { g.Subject, g.Body }) .ToDictionary(g => g.Key, g => string.Join(",", g.Select(m => BuildAddress(m.Address, m.DestText, (AlertDestinationType)m.Type)).ToArray())); if (alerts.Count == 0) { return(true); } foreach (var pair in alerts) { var msg = new MailMessage(); msg.To.Add(pair.Value); msg.Subject = pair.Key.Subject; msg.Body = pair.Key.Body; toSend.Add(msg); } } var engine = new EmailEngine(); var allSent = toSend.Select(engine.Send).All(r => r); if (!allSent) { //TODO: Log info that some alerts could not be sent. } return(true); } catch (Exception) { return(false); } }
public tbl_ACH_Franchisees_Summary GetWSRFee(int frId, DateTime startdate, DateTime enddate) { using (var context = new EightHundredEntities()) { return(context.tbl_ACH_Franchisees_Summary.SingleOrDefault(q => q.FranchiseID == frId && q.WeekEnding >= startdate && q.WeekEnding <= enddate)); } }
public IEnumerable <GoLiveCheck_Result> getOnlineCheck(int FranchiseId) { using (var context = new EightHundredEntities()) { var result = context.GoLiveCheck(FranchiseId).AsQueryable(); return(result.ToArray()); } }
public ActionResult GetLogo() { var configId = GetConfigID(); var context = new EightHundredEntities(); var listofurls = context.tbl_HVAC_ConfigLogoUrl.Where(item => item.ConfigID == configId).ToList(); return(Json(listofurls.Count != 0 ? new { url = listofurls.First().Logourl } : new { url = "../../../Areas/hvac_app/content/bigimage.png" })); }
public ActionResult VerificationHvacPage() { var context = new EightHundredEntities(); var ver = new VerificationHvacData(context, GetFranchiseID(), GetConfigID()); var listOfVerification = ver.RunVerification(); return(View(listOfVerification)); }
public ActionResult GetCompanyTaxes() { var context = new EightHundredEntities(); var franchiseId = GetFranchiseID(); return(Json(context.tbl_TaxRates.Where(item => item.FranchiseId == franchiseId).ToList().Select( item => new { Tax = item.TaxDescription, Value = item.LaborAmount.ToString().Replace(',', '.') }))); }
private List <View_HVAC_APP_Parts> GetListOfPartsFromDB(int priceBookId, EightHundredEntities context, IEnumerable <View_HVAC_APP> list) { var jobcodes = list.Select(item => item.JobCode); var listparts = context.View_HVAC_APP_Parts.Where(item => item.PriceBookID == priceBookId).Where( i => jobcodes.Contains(i.JobCode)).ToList(); return(listparts); }
private List <View_HVAC_APP> GetPackagesFromDB(int priceBookId, EightHundredEntities context, IEnumerable <SystemInfoModelWithParts> mainSystemInfos) { var listofcodes = mainSystemInfos.Select(i => i.JobCode).ToArray(); var list = context.View_HVAC_APP.Where(item => item.PriceBookID == priceBookId).Where( i => listofcodes.Contains(i.JobCode)).ToList(); return(list); }
public static SessionContainer Create(MembershipUser user) { try { if (user == null) { Remove(); return(null); } HttpContext.Current.Session[CONTAINER_KEY] = new SessionContainer { User = user }; var inst = GetInstance(); inst.UserRoles = Roles.GetRolesForUser(user.UserName); inst.UserKey = (Guid)(user.ProviderUserKey ?? Guid.Empty); inst.Franchises = new tbl_Franchise[] { }; inst.IsOwner = inst.UserRoles.Contains(OWNER_ROLE); inst.IsCorporate = inst.UserRoles.Contains(CORPORATE_ROLE); using (var db = new EightHundredEntities()) { IEnumerable <tbl_Franchise> franchises; if (inst.IsCorporate) { franchises = db.tbl_Franchise; } else { using (var ctx = new MembershipConnection()) { franchises = ctx.UserFranchise .Where(uf => uf.UserId == inst.UserKey) .ToArray() .Select(uf => db.tbl_Franchise.SingleOrDefault(f => f.FranchiseID == uf.FranchiseID)) .Where(f => f != null); } } inst.Franchises = franchises.OrderBy(f => f.FranchiseNUmber).Distinct().ToArray(); } inst.SwapBranding = !inst.IsCorporate && inst.Franchises.Any(f => f.FranchiseTypeID == 6); inst.DefaultFranchise = inst.Franchises.FirstOrDefault(f => f.FranchiseStatusID == 7 || inst.ShowInactiveFranchises); inst.CurrentFranchise = inst.DefaultFranchise; return(inst); } catch (Exception ex) { Logger.Log("Error loading the user's session container info.", ex, LogLevel.Error); Remove(); return(null); } }
private IEnumerable <string> GetSelectedSystemsP() { int configID = GetConfigID(); var context = new EightHundredEntities(); var list = context.tbl_HVAC_ConfigSystems.Where(item => item.ConfigID == configID).OrderBy(i => i.OrderNum).Select( item => item.tbl_HVAC_SystemType.SystemTypeName).ToList(); return(list); }
public ActionResult GetForChooseSystem() { //var configID = 1; var context = new EightHundredEntities(); var listOfAll = context.tbl_HVAC_SystemType.Select(item => item.SystemTypeName).ToList(); var selectedList = GetSelectedSystemsP(); return(Json(listOfAll.Except(selectedList).Select(i => new { text = i }), JsonRequestBehavior.AllowGet)); }
private bool GenerateInvoice(EightHundredEntities context, tbl_Job job, Guid userId) { ClearJobTasks(context, job.JobID); UpdatePaymentsInJob(context, job.JobID); var jsonData = context.tbl_HVAC_Answers.Single( item => item.tbl_HVAC_CustomersAnswers.JobID == job.JobID && item.tbl_HVAC_CustomersAnswers.UserID == userId && item.QuestionID == 35).Data; /*{"Jobs": * [ [ * {"Count":"1","JobCode":"LE-HPAH136","Description":"asd","ResAccountCode":"41000","Price":7380,"TotalPrice":"$7,380.00", * "Parts": * [ * {"PartCost":3690,"PartCode":"LE-HPAH136","PartName":"LE-3 Ton Air Handler Electric Heat - 10KW","PartStdPrice":7380,"PartID":503085,"Qty":1} * ],"id":1337316467855}, * {"Count":"1","JobCode":"LE-HPAH136","Description":"asd3","ResAccountCode":"41000","Price":7380,"TotalPrice":"$7,380.00", * "Parts": * [ * {"PartCost":3690,"PartCode":"LE-HPAH136","PartName":"LE-3 Ton Air Handler Electric Heat - 10KW","PartStdPrice":7380,"PartID":503085,"Qty":2,"TotalPrice":"$14,760.00"} * ],"id":1337316467857}, * {"id":"ACC-CMF001","isAccessory":true,"Code":"ACC-CMF001","JobCode":"ACC-CMF001","Description":"1\" Charged Media Filter, 20 x 25","ResAccountCode":"41000","Count":1,"Price":895,"TotalPrice":"$895.00"}, * {"id":"ACC-HUM001","isAccessory":true,"Code":"ACC-HUM001","JobCode":"ACC-HUM001","Description":"Humidifier","ResAccountCode":"41000","Count":3,"Price":595,"TotalPrice":"$1,785.00"} * ], * "MainSystem":{"Parts":[{"PartCost":3690,"PartCode":"LE-HPAH136","PartName":"LE-3 Ton Air Handler Electric Heat - 10KW","PartStdPrice":7380,"PartID":503085,"Qty":1}],"TotalPrice":7380,"id":"LE","AFUE":"80","SEER":"12","JobCodeId":0,"JobCode":"LE-HPAH136","ResAccountCode":"41000","Description":"SEER Rating 12, AFUE 80, LE-3 Ton Air Handler Electric Heat - 10KW","Count":1,"Price":7380},"TotalAmount":24820,"Tax":0,"GrandTotal":24820,"TaxRate":0} */ //{"Jobs":[{"Count":"1","Description":"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical","Price":12488,"TotalPrice":"$12,488.00","Parts":[{"PartCost":6244,"PartCode":"SE-HPGFV30","PartName":"SE-2.5 Ton Gas Furnace Vertical","PartStdPrice":12488,"PartID":503287,"Qty":1}],"id":1331745863188},{"id":"ACC-CMF001","isAccessory":true,"Code":"ACC-CMF001","Description":"1\" Charged Media Filter, 20 x 25","Count":1,"Price":895,"TotalPrice":"$895.00"},{"Count":"1","Description":"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical","Price":12488,"TotalPrice":"$12,488.00","Parts":[{"PartCost":6244,"PartCode":"SE-HPGFV30","PartName":"SE-2.5 Ton Gas Furnace Vertical","PartStdPrice":12488,"PartID":503287,"Qty":1}],"id":1331745863190}],"MainSystem":{"Parts":[{"PartCost":6244,"PartCode":"SE-HPGFV30","PartName":"SE-2.5 Ton Gas Furnace Vertical","PartStdPrice":12488,"PartID":503287,"Qty":1}],"TotalPrice":12488,"id":"SE","AFUE":"29","SEER":"16","JobCodeId":0,"JobCode":"SE-HPGFV30","Description":"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical","Count":1,"Price":12488},"TotalAmount":25871,"Tax":0,"GrandTotal":25871,"TaxRate":0} //var jsonData = "{\"Jobs\":[" + // "{\"JobCode\":\"SE-HPGFV30\",\"Count\":\"1\",\"Description\":\"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical\",\"Price\":12488,\"TotalPrice\":\"$12,488.00\",\"Parts\":[{\"PartCost\":6244,\"PartCode\":\"SE-HPGFV30\",\"PartName\":\"SE-2.5 Ton Gas Furnace Vertical\",\"PartStdPrice\":12488,\"PartID\":503287,\"Qty\":1}],\"id\":1331745863188}," + // "{\"id\":\"ACC-CMF001\",\"isAccessory\":true,\"Code\":\"ACC-CMF001\",\"JobCode\":\"ACC-CMF001\",,\"Description\":\"1\\\" Charged Media Filter, 20 x 25\",\"Count\":1,\"Price\":895,\"TotalPrice\":\"$895.00\"}," + // "{\"JobCode\":\"SE-HPGFV30\",\"Count\":\"1\",\"Description\":\"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical\",\"Price\":12488,\"TotalPrice\":\"$12,488.00\",\"Parts\":[{\"PartCost\":6244,\"PartCode\":\"SE-HPGFV30\",\"PartName\":\"SE-2.5 Ton Gas Furnace Vertical\",\"PartStdPrice\":12488,\"PartID\":503287,\"Qty\":1}],\"id\":1331745863190}]," + // "\"MainSystem\":{\"Parts\":[{\"PartCost\":6244,\"PartCode\":\"SE-HPGFV30\",\"PartName\":\"SE-2.5 Ton Gas Furnace Vertical\",\"PartStdPrice\":12488,\"PartID\":503287,\"Qty\":1}],\"TotalPrice\":12488,\"id\":\"SE\",\"AFUE\":\"29\",\"SEER\":\"16\",\"JobCodeId\":0,\"JobCode\":\"SE-HPGFV30\",\"Description\":\"SEER Rating 16, AFUE 29, SE-2.5 Ton Gas Furnace Vertical\",\"Count\":1,\"Price\":12488}," + // "\"TotalAmount\":25871," + // "\"Tax\":0," + // "\"GrandTotal\":25871," + // "\"TaxRate\":0}"; //var jsonData33 = context.tbl_HVAC_Answers.Single( // item => // item.tbl_HVAC_CustomersAnswers.JobID == jobId && item.tbl_HVAC_CustomersAnswers.UserID == userId && // item.QuestionID == 33).Data; var prMainJobs = DeserialiseMainJobs(jsonData); var prAccessories = DeserialiseAccessoriesJobs(jsonData); SetJobTasks(context, prMainJobs, prAccessories); var pr = JSONHelper.Deserialise <PriceListModel <SystemInfoModelWithParts> >(jsonData); job.SubTotal = decimal.Parse(pr.TotalAmount); job.TaxAmount = decimal.Parse(pr.Tax); job.TotalSales = decimal.Parse(pr.GrandTotal); context.SaveChanges(); return(true); }