Ejemplo n.º 1
0
        public string SendRegisterUserConfirmation(User user)
        {
            string userRegisterWith = null;

            if (user != null)
            {
                if (!(string.IsNullOrEmpty(user.Mobile)))
                {
                    //    SmsHelper.SendRegisterMessage(user.Mobile);
                    userRegisterWith = ApplicationMessages.UserRegisterationType.MOBILE;
                }
                if (!(string.IsNullOrEmpty(user.EmailAddress)))
                {
                    _emailHelper = new APIEmailHelper();

                    if (!_emailHelper.SendRegisterEmail(user.EmailAddress, "Hunger's Click"))
                    {
                        userRegisterWith = ApplicationMessages.UserRegisterationType.EMAILWITHERROR;
                    }
                    else
                    {
                        userRegisterWith = ApplicationMessages.UserRegisterationType.EMAIL;
                    }

                    _emailHelper = null;
                }
            }
            else
            {
                userRegisterWith = ApplicationMessages.UserRegisterationType.USEREXIST;
            }
            return(userRegisterWith);
        }
Ejemplo n.º 2
0
        public bool ForgotPassword(string Email)
        {
            using (_context = new karrykartEntities()) {
                var usr = _context.Users.Where(x => x.EmailAddress == Email).FirstOrDefault();
                if (usr != null)
                {
                    _emailHelper = new APIEmailHelper();
                    string otp = Email.Substring(0, 4) + CommonHelper.GenerateOTP();
                    CommonHelper.SaveOTP(otp, Email);
                    if (_emailHelper.SendOtpEmail(Email, otp, "Hunger's Click"))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        bool SendOtpVerificationToUser(User user)
        {
            if (!(string.IsNullOrEmpty(user.Mobile)))
            {
                //  SmsHelper.SendVerificationMessage(user.Mobile);
                return(true);
            }
            if (!(string.IsNullOrEmpty(user.EmailAddress)))
            {
                _emailHelper = new APIEmailHelper();

                if (_emailHelper.SendVerificationEmail(user.EmailAddress, "Hunger's Click"))
                {
                    _emailHelper = null;
                    return(true);
                }
                else
                {
                    _emailHelper = null;
                    return(false);
                }
            }
            return(false);
        }
Ejemplo n.º 4
0
        public OrderModel CreateOrder(OrderInputModel OrderToCheckout)
        {
            using (_context = new karrykartEntities())
            {
                var cart = _context.Carts.Find(OrderToCheckout.CartID);
                if (cart != null)
                {
                    _cartHelper = new CartHelper();
                    var cartDetails = _cartHelper.GetCart(OrderToCheckout.CartID);
                    var payment     = new Payment()
                    {
                        ID = Guid.NewGuid(), Amount = Convert.ToDecimal(cartDetails.GrandTotal), Type = OrderToCheckout.PaymentType, IsSuccessful = OrderToCheckout.GuestCheckout ? false : true
                    };
                    _context.Payments.Add(payment);
                    _context.SaveChanges();
                    var order = new Order()
                    {
                        ID                = Guid.NewGuid(),
                        CartID            = cart.ID,
                        UserID            = OrderToCheckout.UserID,
                        PaymentID         = payment.ID,
                        Status            = 1,
                        PlaceOn           = DateTime.Now,
                        GuestCheckout     = OrderToCheckout.GuestCheckout,
                        DeliveryAddressID = OrderToCheckout.GuestCheckout?0:OrderToCheckout.AddressID
                    };
                    _context.Orders.Add(order);
                    _context.SaveChanges();

                    foreach (var p in cart.CartProducts)
                    {
                        var prod = new OrderProduct()
                        {
                            OrderID = order.ID, ProductID = p.ProductID, Quantity = p.Quantity
                        };
                        _context.OrderProducts.Add(prod);
                    }
                    _context.SaveChanges();

                    _emailHelper = new APIEmailHelper();
                    _loginHelper = new LoginHelper();
                    UserDetails userDetails = null;
                    if (!OrderToCheckout.GuestCheckout)
                    {
                        var user = _context.Users.Find(OrderToCheckout.UserID);
                        userDetails = _loginHelper.GetUser(user.UserID, OrderToCheckout.AddressID);
                    }
                    else
                    {
                        userDetails = _loginHelper.GetGuestUserDetails(OrderToCheckout.UserID);
                    }
                    var orderHtml = BuildOrderHtml(cartDetails, order, cart, userDetails, GetOrderStatus(order, _context));
                    _emailHelper.SendOrderPlacedEmail(userDetails.FirstName + " " + userDetails.LastName, userDetails.Email, orderHtml);
                    // string smsMsg = "Hi " + user.UserDetails.FirstOrDefault().FirstName + user.UserDetails.FirstOrDefault().LastName + ", thank you for placing order with us. Your order will be confirmed shortly.";
                    //         _smsHelper = new SmsHelper();
                    //         _smsHelper.SendOrderConfirmationToUser(new SmsModel() { Message =smsMsg , Number = contact });
                    // _smsHelper = null;
                    var orderDetail = new OrderModel()
                    {
                        OrderID = order.ID, OrderPlaced = true
                    };
                    return(orderDetail);
                }
            }
            return(null);
        }