public static async Task <ServiceResponseResult> SendActivationEmailToTenant(int tenantId, string tenantEmail, string token, AddTenantToPropertyModel model)
        {
            var nvc = new NameValueCollection();

            nvc.Set("TenantId", tenantId.ToString());
            nvc.Set("Email", tenantEmail);
            nvc.Set("Token", token);
            nvc.Set("PropertyId", model.PropertyId.ToString());
            nvc.Set("StartDate1", model.StartDate.ToString());
            nvc.Set("EndDate1", model.EndDate.ToString());

            //nvc.Set("StartDate", model.StartDate. );
            //nvc.Set("EndDate", model.EndDate );
            nvc.Set("PaymentFrequencyId", model.PaymentFrequencyId.ToString());
            nvc.Set("PaymentAmount", model.PaymentAmount.ToString());
            string url     = UtilService.UrlGenerator(System.Web.HttpContext.Current.Request, "Account/ActivateToBeTenant", UtilService.ToQueryString(nvc));
            string subject = "Property Community: Account Activation";
            string body    =
                "Hello !<br />"
                + $"You have registered to become a tenant at Property Community.<br />"
                + "Please <a target='_blank' href=" + url + "> Click Here </a> to activate<br />";
            MailMessage msg = new MailMessage()
            {
                Subject         = subject,
                SubjectEncoding = System.Text.Encoding.UTF8,
                Body            = body,
                BodyEncoding    = System.Text.Encoding.UTF8,
                IsBodyHtml      = true
            };

            msg.To.Add(tenantEmail);
            try
            {
                await EmailService.SendAsync(msg);

                return(new ServiceResponseResult {
                    IsSuccess = true
                });
            }
            catch (Exception ex)
            {
                return(new ServiceResponseResult {
                    IsSuccess = false
                });
            }
        }
Exemple #2
0
        public static async Task <bool> SendCreateAccountToTenantSendgrid(Person tenant, string email, string temPass, Person owner, string token, string address)
        {
            var nvc = new NameValueCollection();

            nvc.Set("token", token);
            nvc.Set("userId", tenant.Id.ToString());
            string             url  = UtilService.UrlGenerator(System.Web.HttpContext.Current.Request, "Account/Activate", UtilService.ToQueryString(nvc));
            SendGridEmailModel mail = new SendGridEmailModel
            {
                RecipentName  = tenant.FirstName,
                ButtonUrl     = url,
                RecipentEmail = email,
                NewUserName   = email,
                NewPassWord   = temPass,
                OwnerName     = owner.FirstName,
                Address       = address
            };

            try
            {
                await SendEmailWithSendGrid(EmailType.OwnerCreatNewTenantEmail, mail);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemple #3
0
        public static async Task <ServiceResponseResult> SendActivationEmailToTenant(PropertyMyOnboardModel model, Person ownerPerson)
        {
            var nvc = new NameValueCollection();

            nvc.Set("TenantEmail", model.TenantToPropertyModel.TenantEmail);
            string url     = UtilService.UrlGenerator(System.Web.HttpContext.Current.Request, "Account/Login", UtilService.ToQueryString(nvc));
            string subject = "Property Community: Account Activated";
            string body    =
                "Hello !<br />"
                + $"{ownerPerson.FirstName} has added you to be a tenant in his/her property and activated your account on Property Community.<br />";

            MailMessage msg = new MailMessage()
            {
                Subject         = subject,
                SubjectEncoding = System.Text.Encoding.UTF8,
                Body            = body,
                BodyEncoding    = System.Text.Encoding.UTF8,
                IsBodyHtml      = true
            };

            msg.To.Add(model.TenantToPropertyModel.TenantEmail);
            try
            {
                await SendAsync(msg);

                return(new ServiceResponseResult {
                    IsSuccess = true
                });
            }
            catch (Exception ex)
            {
                return(new ServiceResponseResult {
                    IsSuccess = false
                });
            }
        }
Exemple #4
0
        public static ServiceResponseResult AcceptQuote(JobAcceptedModel model, Login login)
        {
            using (var db = new KeysEntities())
            {
                var quote = db.JobQuote.FirstOrDefault(x => x.Id == model.QuoteId);
                if (quote == null)
                {
                    return(new ServiceResponseResult {
                        IsSuccess = false, ErrorMessage = "Can note find quote"
                    });
                }
                quote.IsViewed = true;
                quote.Status   = "accepted";
                var job = new Job
                {
                    ProviderId     = quote.ProviderId,
                    PropertyId     = quote.TenantJobRequest.PropertyId,
                    AcceptedQuote  = quote.Amount,
                    JobDescription = model.JobDescription,
                    JobRequestId   = model.JobRequestId,
                    JobStatusId    = 2,
                    UpdatedBy      = login.Email,
                    CreatedOn      = DateTime.UtcNow,
                    UpdatedOn      = DateTime.UtcNow,
                    CreatedBy      = login.Email,
                    OwnerId        = login.Id
                };
                db.Job.Add(job);
                var marketJob = db.TenantJobRequest.FirstOrDefault(x => x.Id == model.JobRequestId);

                if (marketJob == null)
                {
                    return(new ServiceResponseResult {
                        IsSuccess = false, ErrorMessage = "Can not find job!"
                    });
                }
                marketJob.JobStatusId = 5;
                var otherQuotes = db.JobQuote.Where(x => x.JobRequestId == model.JobRequestId && x.Id != model.QuoteId).ToList();
                otherQuotes.ForEach(x => x.Status = "unsuccessful");
                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(new ServiceResponseResult {
                        IsSuccess = false, ErrorMessage = _error
                    });
                }
                foreach (var item in otherQuotes)
                {
                    var nvc = new NameValueCollection();
                    nvc.Add("status", "unsuccessful");


                    string             url  = UtilService.UrlGenerator(System.Web.HttpContext.Current.Request, "/Companies/Manage/MyQuotes", UtilService.ToQueryString(nvc));
                    SendGridEmailModel mail = new SendGridEmailModel
                    {
                        RecipentName  = item.ServiceProvider.Company.Name,
                        ButtonText    = "",
                        ButtonUrl     = url,
                        RecipentEmail = item.ServiceProvider.Company.CreatedBy,
                        JobTitle      = item.TenantJobRequest.JobDescription ?? "No Description",
                    };
                    EmailService.SendEmailWithSendGrid(EmailType.DeclineQuote, mail);
                }
                return(new ServiceResponseResult {
                    IsSuccess = true
                });
            }
        }