public ActionResult NewRevenue(int Id) { var model = new ResolutionRevenueModel(); model.OwnerPayoutId = Id; model.PropertyCode = string.Empty; ViewBag.Title = "New Resolution"; ViewBag.ButtonText = "Create New Resolution"; ViewBag.NewResolution = true; return(PartialView("_ResolutionEditPartial", model)); }
public JsonResult ConvertRevenue(int id) { if (!AuthorizationProvider.CanEditRevenue()) { return(Forbidden()); } try { var reservationProvider = new ReservationRevenueProvider(_dbContext); var entity = reservationProvider.Retrieve(id); // create resolution entity var resolutionModel = new ResolutionRevenueModel(); resolutionModel.ResolutionDate = entity.PayoutDate; resolutionModel.OwnerPayoutId = entity.OwnerPayoutId; resolutionModel.ConfirmationCode = entity.ConfirmationCode; resolutionModel.PropertyCode = entity.PropertyCode; resolutionModel.ResolutionType = "Cancellation"; resolutionModel.ResolutionDescription = "Converted from Reservation"; resolutionModel.ResolutionAmount = entity.TotalRevenue; resolutionModel.IncludeOnStatement = true; resolutionModel.Impact = string.Empty; resolutionModel.ApprovalStatus = RevenueApprovalStatus.NotStarted; var resolutionProvider = new ResolutionRevenueProvider(_dbContext); resolutionProvider.Create(resolutionModel); resolutionProvider.Commit(); // set reservation revenue to 0 and excluded from statement entity.TotalRevenue = 0; entity.IncludeOnStatement = false; reservationProvider.Update(id, entity); reservationProvider.Commit(); var provider = new OwnerPayoutProvider(_dbContext); provider.UpdateOwnerPayoutMatchStatus(entity.OwnerPayoutId); return(Json("success", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { string message = string.Format("Delete Reservation {0} fails. {1}", id.ToString(), ex.Message + ex.StackTrace); return(InternalError(message, "fail", ex)); } }
public JsonResult SaveRevenue(ResolutionRevenueModel form) { if (!AuthorizationProvider.CanEditRevenue()) { return(Forbidden()); } try { // Impact list is defined in lookup table; Advance Payout does not have a confirmation code if (form.Impact == "Advance Payout") { form.ConfirmationCode = string.Empty; } var dataProvider = new ResolutionRevenueProvider(_dbContext); if (form.ResolutionId == 0) // new { dataProvider.Create(form); } else // update { dataProvider.Update(form.ResolutionId, form); } dataProvider.Commit(); // ReservationId will be filled for new reservation by EF // get the resolution ID if (form.ResolutionId == 0) { form.ResolutionId = dataProvider.GetKey(form); } var provider = new OwnerPayoutProvider(_dbContext); provider.UpdateOwnerPayoutMatchStatus(form.OwnerPayoutId); return(Json(form.ResolutionId.ToString(), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { var innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty; string message = string.Format("Saving Resolution {0} fails. {1},{2}", form.ResolutionId.ToString(), ex.Message, innerErrorMessage); return(InternalError(message, string.Empty, ex)); } }
public JsonResult SaveResolution(ResolutionRevenueModel form) { // delegate to resolution controller service to save var delegatedController = DependencyResolver.Current.GetService <ResolutionController>(); delegatedController.ControllerContext = ControllerContext; var result = delegatedController.SaveRevenue(form); // return the owner payout Id instead of resolution Id try { int id = int.Parse(result.Data.ToString()); return(Json(form.OwnerPayoutId.ToString(), JsonRequestBehavior.AllowGet)); } catch { return(result); } }