public PartialViewResult Approve(InquiriesValidation form) { try { InquiryProvider inquiryProvider = new InquiryProvider(_dbContext); PropertyProvider propertyProvider = new PropertyProvider(_dbContext); InquiriesValidation inquiry = inquiryProvider.Retrieve(form.Id); form.CPL = propertyProvider.Retrieve(inquiry.PropertyCode); inquiry.Doesitrequire2pricingteamapprovals = form.Doesitrequire2pricingteamapprovals; inquiry.PricingApprover1 = form.PricingApprover1; inquiry.PricingApprover2 = form.PricingApprover2; inquiry.PricingDecision1 = form.PricingDecision1; inquiry.PricingReason1 = form.PricingReason1; inquiry.ApprovedbyOwner = form.ApprovedbyOwner; inquiryProvider.Update(inquiry.Id, inquiry); inquiryProvider.Commit(); } catch (Exception ex) { // TODO: Log error this.ModelState.AddModelError("", ex); } return(PartialView("ApprovePartial", form)); }
public JsonResult SaveApproveStatus(InquiriesValidation form) { if (!AuthorizationProvider.IsInquiryEditor()) { string message = string.Format("User '{0}' does not have permission to save approval status for Inquiry {1}.", this.User.Identity.Name, form.Id.ToString()); DojoLogger.Warn(message, typeof(InquiryController)); return(Json("denied", JsonRequestBehavior.AllowGet)); } try { InquiryProvider inquiryProvider = new InquiryProvider(_dbContext); InquiriesValidation inquiry = inquiryProvider.Retrieve(form.Id); SetApproveFields(inquiry, form); inquiryProvider.Update(inquiry.Id, inquiry); inquiryProvider.Commit(); return(Json(form.Id.ToString(), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { string message = string.Format("Save Apporval Ststus for Inquiry {0} fails. {1}", form.Id.ToString(), ex.Message + ex.StackTrace); DojoLogger.Error(message, typeof(InquiryController)); } return(Json(string.Empty, JsonRequestBehavior.AllowGet)); }
public PartialViewResult Edit(InquiriesValidation form) { try { if (ModelState.IsValid) { InquiryProvider inquiryProvider = new InquiryProvider(_dbContext); inquiryProvider.Update(form.Id, form); inquiryProvider.Commit(); } } catch (Exception ex) { // TODO: Log error this.ModelState.AddModelError("", ex); } ViewBag.Accounts = (new AirbnbAccountProvider(_dbContext)).AggregatedAccounts(); ViewBag.Properties = (new PropertyProvider(_dbContext)).AggregatedProperties(); return(PartialView("EditPartial", form)); }
public JsonResult Save(InquiriesValidation form) { if (!AuthorizationProvider.IsInquiryEditor()) { string message = string.Format("User '{0}' does not have permission to save Inquiry {1}.", this.User.Identity.Name, form.Id.ToString()); DojoLogger.Warn(message, typeof(InquiryController)); return(Json("denied", JsonRequestBehavior.AllowGet)); } try { // treat checkin and checkout date as Hawaii time zone and covert it to UTC by adding 11 hours. if (form.Check_inDate != null) { form.Check_inDate = form.Check_inDate.Value.Date.AddHours(11); } if (form.Check_outDate != null) { form.Check_outDate = form.Check_outDate.Value.Date.AddHours(11); } InquiryProvider inquiryProvider = new InquiryProvider(_dbContext); string message = string.Format("saving inquiry: name: {0} team: {1} property: {2} checkin: {3} checkout: {4} payout: {5}", form.GuestName, form.InquiryTeam, (!string.IsNullOrEmpty(form.PropertyCode) ? form.PropertyCode : "Invalid"), (form.Check_inDate != null ? form.Check_inDate.Value.ToShortDateString() : "Invalid"), (form.Check_outDate != null ? form.Check_outDate.Value.ToShortDateString() : "Invalid"), (form.TotalPayout != null ? form.TotalPayout.Value.ToString() : "Invalid")); DojoLogger.Trace(message, typeof(InquiryController)); if (form.Id == 0) // new inquiry { if (inquiryProvider.Exist(form.PropertyCode, form.GuestName, form.Check_inDate.Value, form.Check_outDate.Value)) { Response.StatusCode = (int)System.Net.HttpStatusCode.Conflict; // code = 409 return(Json(string.Empty, JsonRequestBehavior.AllowGet)); } else { SetRelatedFields(form); inquiryProvider.Create(form); } } else // updating inquiry { InquiriesValidation inquiry = inquiryProvider.Retrieve(form.Id); SetRelatedFields(inquiry, form); // need to set CreatedBy and CreatedDate a they are not part of form form.CreatedDate = inquiry.CreatedDate; form.CreatedBy = inquiry.CreatedBy; inquiryProvider.Update(inquiry.Id, inquiry); } inquiryProvider.Commit(); // Id will be filled for new inquiry by EF PropertyProvider propertyProvider = new PropertyProvider(_dbContext); ViewBag.Properties = propertyProvider.AggregatedProperties(); return(Json(form.Id.ToString(), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { string message = string.Format("Saving Inquiry {0} fails. {1}", form.Id.ToString(), ex.Message); DojoLogger.Error(message, typeof(InquiryController)); Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError; return(Json(string.Empty, JsonRequestBehavior.AllowGet)); } }