Example #1
0
        public ActionResult ConfirmRegistration(String email)
        {
            NotificationService notificationService = new NotificationService();
            notificationService.ConfirmationRegistration(email);

            ViewBag.Message = Resources.UIStrings.SuccessRegistration;
            return RedirectToAction("Login", "Account");
        }
Example #2
0
        public static ApplyRiderResponse ApplyToOrder_ByRider(ApplyByRiderRequestmodel model)
        {
            string newStatus = "";

            using (var dbContext = new DeliversEntities())
            {
                var order = dbContext.Orders.FirstOrDefault(o => o.Id.ToString() == model.OrderId);
                if (order != null)
                {
                    //  var combinedOrders = dbContext.Orders.Where(o => o.SerialNo == order.SerialNo).ToList();
                    //  var ifSomeoneAppliedAlready = combinedOrders.Any(o => o.Status != OrderHistoryEnu.ConfirmedByRestaurant.Value);
                    var ifSomeoneAppliedAlready = order.Status != OrderHistoryEnu.ConfirmedByRestaurant.Value;
                    if (ifSomeoneAppliedAlready)
                    {
                        return(new ApplyRiderResponse
                        {
                            isSuccesss = false,
                            Message = "Order has been assigned to some other rider."
                        });
                    }

                    var notAvaialbeORders = 0;

                    var combinedOrders = new List <Order> {
                        order
                    };                                               // this one

                    foreach (var dbO in combinedOrders)
                    {
                        newStatus = OrderHistoryEnu.ConfirmedByRider.Value;
                        if (dbO.Status != OrderHistoryEnu.ConfirmedByRestaurant.Value)
                        {
                            notAvaialbeORders++;
                            continue;
                        }

                        dbO.Status    = newStatus;
                        dbO.PickedBy  = model.UserId;
                        dbO.UpdatedAt = CommonService.GetSystemTime();

                        var currentHis = dbContext.OrderHistories.FirstOrDefault(d => d.OrderId.ToString() == dbO.Id.ToString() && d.IsCurrent);
                        if (currentHis != null)
                        {
                            currentHis.IsCurrent = false;
                        }

                        dbContext.OrderHistories.Add(new OrderHistory
                        {
                            OrderId   = dbO.Id,
                            DateTime  = CommonService.GetSystemTime(),
                            Status    = newStatus,
                            IsCurrent = true
                        });
                    }
                    if (notAvaialbeORders == 0)
                    {
                        dbContext.SaveChanges();
                        notAvaialbeORders = 0;
                        // generate notifications
                        NotificationService.ProcessNotificationRequest(newStatus, order.Id);
                        return(new ApplyRiderResponse
                        {
                            isSuccesss = true,
                            Message = "Order has been assigned to you."
                        });
                    }
                    else
                    {
                        return(new ApplyRiderResponse
                        {
                            isSuccesss = false,
                            Message = "Order/part of order has been assigned to some other rider."
                        });
                    }
                }
                return(new ApplyRiderResponse
                {
                    isSuccesss = false,
                    Message = "Order does not exist."
                });
            }
        }
Example #3
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                try
                {
                    WebSecurity.CreateUserAndAccount(model.UserName, model.Password, propertyValues: new
                        {
                            Email = model.Email,
                            IsBlocked = (model.IsBlocked = true)
                        });
                    var service = new NotificationService();
                    service.RegisterUser(model.Email, model.UserName);
                    ViewBag.Message = Resources.UIStrings.AfterRegisterString;
                    return RedirectToAction("Index", "Home");
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
Example #4
0
        public static PlaceOrderResponseModel Place(PlaceOrderRequestModel request, string orderBy)
        {
            DbGeography userLoc       = null;
            var         orderstatus   = OrderHistoryEnu.Placed.Value;
            var         estimatedTime = "45 minutes away";
            var         orderIds      = new List <string>();

            if (!string.IsNullOrEmpty(request.Cords) && request.Cords != "")
            {
                var latlng = request.Cords.Split('_').ToList();
                if (latlng.Count == 2)
                {
                    userLoc = CommonService.ConvertLatLonToDbGeography(latlng[1], latlng[0]); // lat _ lng
                }
            }


            using (var dbContext = new DeliversEntities())
            {
                foreach (var item in request.Items)
                {
                    var dbItem = dbContext.ItemDetails.FirstOrDefault(i => i.Id == item.ItemId);
                    if (dbItem != null)
                    {
                        item.RestId = dbItem.ListItemId;
                    }
                }
            }


            var rest_groups = request.Items.GroupBy(item => item.RestId).ToList();
            var serial      = Guid.NewGuid().ToString().Substring(0, 6).ToUpper();

            using (var dbContext = new DeliversEntities())
            {
                foreach (var localG in rest_groups)
                {
                    var localList   = localG.ToList();
                    var totalAmount = localList.Sum(i => ItemDetailsService.GetItemDetailLocalById(i.ItemId).Price *i.Quantity);
                    var order       = new Order
                    {
                        Address       = request.Address,
                        Instructions  = request.Instructions,
                        Status        = orderstatus,
                        OrderBy       = orderBy,
                        Amount        = totalAmount,
                        DateTime      = CommonService.GetSystemTime(),
                        Cords         = userLoc,
                        EstimatedTime = estimatedTime,
                        SerialNo      = serial,
                        PickedBy      = Guid.Empty.ToString(),
                        UpdatedAt     = CommonService.GetSystemTime(),
                        DeliveryCost  = CommonService.GetDeliveryAmount()
                    };
                    dbContext.Orders.Add(order);

                    dbContext.OrderHistories.Add(new OrderHistory
                    {
                        OrderId   = order.Id,
                        DateTime  = CommonService.GetSystemTime(),
                        Status    = orderstatus,
                        IsCurrent = true
                    });
                    foreach (var item in localList)
                    {
                        var itmObj = new OrderDetail
                        {
                            OrderId  = order.Id,
                            ItemId   = item.ItemId,
                            Quantity = item.Quantity,
                            RestId   = item.RestId
                        };
                        dbContext.OrderDetails.Add(itmObj);
                    }
                    dbContext.SaveChanges();

                    // generate notification
                    NotificationService.ProcessNotificationRequest(orderstatus, order.Id);
                    orderIds.Add(order.Id.ToString());
                }

                return(new PlaceOrderResponseModel {
                    EstimatedTime = estimatedTime, OrderIds = orderIds, SerailNo = serial
                });
            }
        }