Ejemplo n.º 1
0
        // [ValidateAntiForgeryToken]
        public async Task <JsonResult> ApplicationAccepted(AcceptAndDeclineRentalApplicationModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { Success = false }));
            }
            var user   = User.Identity.Name;
            var login  = AccountService.GetLoginByEmail(user);
            var result = PropertyService.AcceptApplication(model, login);


            // send email here
            if (result.IsSuccess)
            {
                var tenantPersonDetails = AccountService.GetPersonById(model.TenantId);
                var tenatLoginDetails   = AccountService.GetLoginById(model.TenantId);


                var property      = db.Property.FirstOrDefault(x => x.Id == model.PropertyId);
                var addressString = "";
                if (property != null)
                {
                    var address = PropertyService.GetAddressById(property.AddressId);
                    if (address != null)
                    {
                        if (address.Street != "" && address.City != "")
                        {
                            addressString = address.Number + " " + address.Street + ", " + address.Suburb + ", " + address.City + ", " + address.PostCode;
                        }
                    }
                }

                string             url  = UtilService.UrlGenerator(System.Web.HttpContext.Current.Request, "Tenants/Home/MyRentals");
                SendGridEmailModel mail = new SendGridEmailModel
                {
                    RecipentName  = tenantPersonDetails.FirstName,
                    ButtonText    = "",
                    ButtonUrl     = url,
                    RecipentEmail = tenatLoginDetails.Email,
                    Address       = addressString,
                };
                await EmailService.SendEmailWithSendGrid(EmailType.AcceptRentalApplication, mail);

                return(Json(new { Success = result.IsSuccess }));
            }
            return(Json(new { Success = result.IsSuccess, Msg = result.ErrorMessage }));
        }
Ejemplo n.º 2
0
        // [ValidateAntiForgeryToken]
        public JsonResult ApplicationDeclined(AcceptAndDeclineRentalApplicationModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { Success = false }));
            }
            var user   = User.Identity.Name;
            var login  = AccountService.GetLoginByEmail(user);
            var result = PropertyService.DeclineApplication(model, login);

            if (result.IsSuccess)
            {
                return(Json(new { Success = result.IsSuccess }));
            }
            else
            {
                return(Json(new { Success = result.IsSuccess, Msg = result.ErrorMessage }));
            }
        }