Ejemplo n.º 1
0
        public JsonResult Update(string model)
        {
            if (!AuthorizationProvider.CanEditRevenue())
            {
                return(Forbidden());
            }

            var codeModel = JsonConvert.DeserializeObject <MissingPropertyCodesModel>(model);

            try
            {
                var dataProvider = new ReservationRevenueProvider(_dbContext);
                var entity       = dataProvider.Retrieve(codeModel.ReservationId);
                entity.PropertyCode = codeModel.PropertyCode;
                dataProvider.Update(codeModel.ReservationId, entity);
                dataProvider.Commit();
                return(Json(codeModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Saving Property Code for Reservation {0:d} fails. {1},{2}", codeModel.ReservationId, ex.Message, innerErrorMessage);
                return(InternalError(message, string.Empty, ex));
            }
        }
Ejemplo n.º 2
0
        public JsonResult DeleteRevenue(int id)
        {
            if (!AuthorizationProvider.CanEditRevenue())
            {
                return(Forbidden());
            }

            try
            {
                var dataProvider = new ReservationRevenueProvider(_dbContext);
                var entity       = dataProvider.Retrieve(id);

                dataProvider.Delete(id);
                dataProvider.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));
            }
        }
Ejemplo n.º 3
0
        public ActionResult SplitRevenue(int Id)
        {
            if (!AuthorizationProvider.CanEditRevenue())
            {
                return(Forbidden());
            }

            var model = new ResevationSplitModel();

            try
            {
                var provider = new ReservationRevenueProvider(_dbContext);
                var entity   = provider.Retrieve(Id);
                if (entity != null)
                {
                    model.ReservationId     = Id;
                    model.PropertyCode      = entity.PropertyCode;
                    model.ConfirmationCode  = entity.ConfirmationCode;
                    model.ReservationAmount = entity.TotalRevenue;
                    ViewBag.Title           = "Split Reservation";
                }
            }
            catch
            {
            }
            return(PartialView("_ReservationSplitPartial", model));
        }
Ejemplo n.º 4
0
        public JsonResult RevenueView(DateTime month, string propertyCode)
        {
            if (!AuthorizationProvider.CanViewRevenue())
            {
                return(Forbidden());
            }

            ReservationRevenueProvider provider = new ReservationRevenueProvider(_dbContext);
            var viewModel = provider.Retrieve(month, propertyCode);

            return(Json(viewModel, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public ActionResult EditRevenue(int Id)
        {
            if (!AuthorizationProvider.CanEditRevenue())
            {
                return(Forbidden());
            }

            var provider    = new ReservationRevenueProvider(_dbContext);
            var reservation = provider.Retrieve(Id);

            ViewBag.Title      = "Edit Reservation";
            ViewBag.ButtonText = string.Format("Update Reservation for Property {0}", reservation.PropertyCode);
            return(PartialView("_ReservationEditPartial", reservation));
        }
Ejemplo n.º 6
0
        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));
            }
        }
Ejemplo n.º 7
0
        public ActionResult DetailInfo(int id)
        {
            if (!AuthorizationProvider.CanViewRevenue())
            {
                return(Forbidden());
            }

            ViewBag.EditClass = " app-field-readonly";
            var details = new ReservationRevenueModel();

            try
            {
                var provider = new ReservationRevenueProvider(_dbContext);

                ViewBag.Title = "View Reservation Details";
                details       = provider.Retrieve(id);
                if (details == null)
                {
                    details = new ReservationRevenueModel();
                }
                // append property code to confirmation code for view-only mode
                if (!string.IsNullOrEmpty(details.PropertyCode))
                {
                    if (string.IsNullOrEmpty(details.ConfirmationCode))
                    {
                        details.ConfirmationCode = string.Empty;
                    }
                    details.ConfirmationCode += " | " + details.PropertyCode;
                }

                return(PartialView("_ReservationEditPartial", details));
            }
            catch (Exception ex)
            {
                string message = string.Format("Retrieve Reservation Details fails. {0}", ex.Message);
                DojoLogger.Error(message, typeof(PropertyController));
            }

            return(PartialView("_ReservationEditPartial", details));
        }
Ejemplo n.º 8
0
        public JsonResult SaveNote(int id, string note)
        {
            if (!AuthorizationProvider.CanEditRevenue())
            {
                return(Forbidden());
            }

            try
            {
                var dataProvider = new ReservationRevenueProvider(_dbContext);
                var entity       = dataProvider.Retrieve(id);
                entity.ApprovedNote = note;
                dataProvider.Update(id, entity);
                dataProvider.Commit();
                return(Json(id.ToString(), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Saving Reservation {0:d} fails. {1},{2}", id, ex.Message, innerErrorMessage);
                return(InternalError(message, string.Empty, ex));
            }
        }
Ejemplo n.º 9
0
        public JsonResult ChangePropertyCode(ResevationTetrisModel form)
        {
            if (!AuthorizationProvider.CanEditRevenue())
            {
                return(Forbidden());
            }

            try
            {
                var dataProvider = new ReservationRevenueProvider(_dbContext);
                var entity       = dataProvider.Retrieve(form.ReservationId);
                entity.PropertyCode = form.NewPropertyCode;
                dataProvider.Update(form.ReservationId, entity);
                dataProvider.Commit();
                return(Json(form.ReservationId.ToString(), JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Changing Reservation {0:d} property code to {1} fails. {2},{3}", form.ReservationId, form.NewPropertyCode, ex.Message, innerErrorMessage);
                return(InternalError(message, string.Empty, ex));
            }
        }