public Status<bool> Interested(EmailListingInterestedModel model)
        {
            //create message
            var message = new MailMessage { Subject = model.LandlordEmail };
            message.To.Add(model.LandlordEmail);

            //create model for it
            ViewData = new System.Web.Mvc.ViewDataDictionary(model);

            //render it
            PopulateBody(message, viewName: "Interested");

            //send it
            return this.SendMessage(message);
        }
Beispiel #2
0
        public Status <bool> Interested(EmailListingInterestedModel model)
        {
            //create message
            var message = new MailMessage {
                Subject = model.LandlordEmail
            };

            message.To.Add(model.LandlordEmail);

            //create model for it
            ViewData = new System.Web.Mvc.ViewDataDictionary(model);

            //render it
            PopulateBody(message, viewName: "Interested");

            //send it
            return(this.SendMessage(message));
        }
 public Status<bool> Interested(EmailListingInterestedModel model)
 {
     return SendMail(model, "listing/interested");
 }
        /// <summary>
        /// Creates the interest in building from the user to the current
        /// listing.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <param name="listingId">The listing id.</param>
        /// <returns>
        /// A status of whether or not the interest was created.
        /// </returns>
        public Status<UserInterest> CreateInterestInBuilding(string username, long listingId, string message)
        {
            if (listingId == 0)
                return Status.ValidationError<UserInterest>(null, "listingId", "listingId is required");

            if (string.IsNullOrWhiteSpace(username))
                return Status.ValidationError<UserInterest>(null, "username", "username is required");

            using (var context = new RentlerContext())
            {
                try
                {
                    User user = (from u in context.Users
                                 where u.Username == username
                                 select u).SingleOrDefault();

                    if (user == null)
                        return Status.NotFound<UserInterest>();

                    UserInterest newInterest = new UserInterest()
                    {
                        BuildingId = listingId,
                        UserId = user.UserId,
                        Message = message
                    };

                    context.UserInterests.Add(newInterest);
                    context.SaveChanges();

                    // loads the building, which generated this interest, into newInterest
                    context.Entry(newInterest).Reference(e => e.Building).Load();

                    // notify landlord of interest
                    // TODO: if we are unable to send this email we need a way to allow the user
                    // to re-notify the Landlord without requiring them to continue to create
                    // interests
                    EmailListingInterestedModel model = new EmailListingInterestedModel(newInterest);
                    mailer.Interested(model);

                    return Status.OK<UserInterest>(newInterest);
                }
                catch (Exception ex)
                {
                    // log exception
                    return Status.Error<UserInterest>("System was unable to create interest", null);
                }
            }
        }
Beispiel #5
0
 public Status <bool> Interested(EmailListingInterestedModel model)
 {
     return(SendMail(model, "listing/interested"));
 }
 public ActionResult Interested(EmailListingInterestedModel model)
 {
     return Json(mailer.Interested(model));
 }