Ejemplo n.º 1
0
        public ActionResult SelectTaxi(string pickFrom, string dropTo, string fromPostCode, string toPostCode, string selected, string journeyType, string distancePreview, string stops, string bonusToken = null)
        {
            ViewBag.PickFrom = pickFrom;
            ViewBag.DropTo   = dropTo;

            ViewBag.FromPostCode = fromPostCode;
            ViewBag.ToPostCode   = toPostCode;

            ViewBag.Selected = selected;

            ViewBag.JourneyType     = journeyType;
            ViewBag.DistancePreview = distancePreview;

            var site = _db.Site();

            var fare = _db.Fares.FirstOrDefault(f => f.From == pickFrom && f.To == dropTo && f.SiteToken == site.Token) ??
                       _db.Fares.FirstOrDefault(f => f.From == dropTo && f.To == pickFrom && f.SiteToken == site.Token);

            if (fare == null)
            {
                fare = _db.Fares.FirstOrDefault(f => f.From == fromPostCode && f.To == toPostCode && f.SiteToken == site.Token) ??
                       _db.Fares.FirstOrDefault(f => f.From == toPostCode && f.To == fromPostCode && f.SiteToken == site.Token);
            }

            if (fare != null)
            {
                ViewBag.Predefined = fare;
            }

            return(View(_db));
        }
Ejemplo n.º 2
0
        public JsonResult ContactUs(string message, string email = null, string name = null, string phone = null)
        {
            var site = db.Site();

            var body = "";

            if (!name.IsEmpty())
            {
                body += "<strong>Name:</strong> " + name + "<br /><br />";
            }
            if (!name.IsEmpty())
            {
                body += "<strong>Email:</strong> " + email + "<br /><br />";
            }
            if (!name.IsEmpty())
            {
                body += "<strong>Phone:</strong> " + phone + "<br /><br />";
            }

            body += "<strong>Message:</strong><br /><br /><blockquote>" + message + "</blockquote><br /><br />";
            body += "<strong>Sent from:</strong> " + site.Name + " ( " + site.URL + " )";

            var subject = "Contact message from " + site.URL;

            try
            {
                db.NotifyAdmin("Contact", body);
                db.SendEmailToAdmin(subject, body);
                return(Json(true));
            }
            catch
            {
                return(Json(false));
            }
        }
Ejemplo n.º 3
0
        public ActionResult Preview(string token, string type)
        {
            var db      = new CabDataContext();
            var booking = db.Jobs.FirstOrDefault(j => j.ConfirmationToken == token);

            if (booking == null)
            {
                return(Json("<h2>Booking not found.</h2>", JsonRequestBehavior.AllowGet));
            }

            if (type == "confirm")
            {
                booking.IsConfirmed = true;
                db.SubmitChanges();

                booking.JobConfirmationNotification(db);
                db.SendEmailToAdmin("Booking Confirmed", "Booking confirmed by " + booking.Name + " ( " + booking.Email + " ).");

                booking.SendBookingConfirmedEmail(db.Site());

                var notifications = db.Notifications.Where(n => n.Receiver == booking.ClientToken && n.Type == JobType.SentCodeForJob);
                foreach (var notification in notifications)
                {
                    notification.Status = "Read";
                    db.SubmitChanges();
                }
            }

            if (type == "cancel")
            {
                booking.IsConfirmed = false;
                db.SubmitChanges();

                var body = "A customer ( " + booking.Name + " : " + booking.CellNumber + " ) want to cancel his booking number #" + booking.JobNumber + " <a href=\"http://" + (db.Site().URL + "/confirm-booking.html#details=" + booking.ConfirmationToken) + "\">View Booking Details</a>";
                db.SendEmailToAdmin("Customer want to cancel his booking", body);
            }

            return(View(booking));
        }
Ejemplo n.º 4
0
        public JsonResult New()
        {
            var form = Request.Form;

            string
                name       = form["name"],
                password   = form["password"],
                email      = form["email"],
                address    = form["address"],
                postalCode = form["postalCode"],
                state      = form["state"],
                city       = form["city"],
                country    = form["country"],
                cellPhone  = form["cellPhone"],
                subscribe  = form["subscribe"];

            if (db.Clients.Any(a => a.Email == email))
            {
                return(Json(new { error = "This email address is being used by someone else. Please pick a unique email address." }));
            }

GoBack:
            var token = RandomNumbers.GetRandomNumbers();

            if (db.Clients.Any(c => c.Token == token))
            {
                goto GoBack;
            }

BackAgain:
            var confirmationToken = RandomNumbers.GenerateCoupen();

            if (db.Clients.Any(c => c.ConfirmationToken == confirmationToken))
            {
                goto BackAgain;
            }

            var client = new Client
            {
                Name                = name,
                Password            = BCrypt.HashPassword(password, BCrypt.GenerateSalt(8)),
                Email               = email.ToLower(),
                Address             = address,
                PostalCode          = postalCode,
                State               = state,
                MobilePhone         = cellPhone,
                HomePhone           = "",
                Token               = token,
                City                = city,
                Country             = country,
                SubscribeNewsletter = subscribe == "1",
                IsConfirmed         = false,
                ConfirmationToken   = confirmationToken,
                RegistrationDate    = UKTime.Now
            };

            try
            {
                db.Clients.InsertOnSubmit(client);
                db.SubmitChanges();

                client.SendEmail(db.Site());

                return(Json(new
                {
                    name = client.Name,
                    cell = client.MobilePhone,
                    email = client.Email,
                    landline = client.HomePhone
                }));
            }
            catch
            {
                return(Json(new
                {
                    error = "Currently we're unable to send you a confirmation code via email. We apologize for this inconvenience.\n\n"
                            + "Our admin is being alerted about this situation. He'll contact you soon.\n\n"
                            + "Please check your email 10 minutes later.",
                    isEmailError = true
                }));
            }
        }
Ejemplo n.º 5
0
        public static void SendEmailToAdmin(this CabDataContext db, string subject, string body, string email = null)
        {
            var site = db.Site();

            new Live(email ?? "*****@*****.**", site).SendEmail(subject, body, email ?? "*****@*****.**");
        }
Ejemplo n.º 6
0
        public JsonResult Confirm(string token, string type, string password, bool isEmail = false)
        {
            var db = new CabDataContext();

            switch (type)
            {
            case "job":
            {
                var booking = db.Jobs.FirstOrDefault(j => j.ConfirmationToken == token);

                if (booking == null || booking.IsConfirmed)
                {
                    db.NotifyOperator("Unknown Error", "A customer tried to confirm booking that not exists or deleted. Booking token provided is: " + token);
                    return(Json("No such booking found!"));
                }

                if (isEmail && booking.Email != password)
                {
                    return(Json("Invalid email or you've not one who booked the job!"));
                }

                if (!isEmail)
                {
                    var client = LoginHelper.Client;
                    if (client == null || BCrypt.CheckPassword(password, client.Password) == false)
                    {
                        return(Json("Invalid password."));
                    }
                }

                booking.IsConfirmed = true;
                db.SubmitChanges();

                booking.JobConfirmationNotification(db);
                db.SendEmailToAdmin("Booking Confirmed", "Booking confirmed by " + booking.Name + " ( " + booking.Email + " ).");

                var site    = db.Site();
                var subject = booking.Name + ": Your booking confirmed successfully!";
                var body    = "Dear " + booking.Name + "!<br /><br />You booking number #" + booking.JobNumber + " confirmed successfully.";
                new Live(site.BookingEmail, site).SendEmail(subject, body, booking.Email);

                var notifications = db.Notifications.Where(n => n.Receiver == booking.ClientToken && n.Type == JobType.SentCodeForJob);
                foreach (var notification in notifications)
                {
                    notification.Status = "Read";
                    db.SubmitChanges();
                }

                return(Json(true));
            }

            case "change-password":
            {
                var client = db.Clients.FirstOrDefault(c => c.ForgotPasswordToken == token);
                if (client == null)
                {
                    return(Json(false));
                }

                client.Password            = BCrypt.HashPassword(password, BCrypt.GenerateSalt(8));
                client.ForgotPasswordToken = null;

                db.SubmitChanges();

                return(Json(true));
            }

            case "account":
            {
                var client = db.Clients.FirstOrDefault(c => c.ConfirmationToken == token);
                if (client == null || BCrypt.CheckPassword(password, client.Password) == false)
                {
                    return(Json(false));
                }

                client.IsConfirmed      = true;
                client.RegistrationDate = UKTime.Now;

                db.SubmitChanges();

                client.ClientConfirmationNotification(db);

                client.Token.AddCookie();
                db.ValidateCookie();

                db.SendEmailToAdmin("Confirmed Account", client.Name + " ( " + client.Email + " ) confirmed his account.");

                db.GetDiscountToken("5");

                return(Json(true));
            }
            }

            return(Json(false));
        }