Exemplo n.º 1
0
        public ActionResult CodeRetrival()
        {
            try
            {
                if (Session["UserID"] == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }

                Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1();
                DailyOrder DO           = new DailyOrder();
                var        dbcode       = Entity.DailyStatusChange().LastOrDefault();
                var        orderdetails = Entity.DailyOrders.Where(q => q.Date.Day == DateTime.Now.Day && q.Date.Month == DateTime.Now.Month).ToList();

                var code = orderdetails.Where(q => Convert.ToDecimal(q.Code) == Convert.ToDecimal(dbcode.rcode) && q.OrderId == dbcode.OrderId).ToList();
                if (code.Count == 0)
                {
                    var Orders = Entity.DailyOrderData().Where(q => q.Date.Day == DateTime.Now.Day && q.Date.Month == DateTime.Now.Month).OrderBy(q => q.Status).ToList();
                    return(View(Orders));
                }
                else
                {
                    code[0].Status = "Delivered";
                    Entity.Entry(code[0]).State = System.Data.Entity.EntityState.Modified;
                    Entity.SaveChanges();
                    var Orders = Entity.DailyOrderData().Where(q => q.Date.Day == DateTime.Now.Day && q.Date.Month == DateTime.Now.Month).OrderBy(q => q.Status).ToList();
                    return(View(Orders));
                }
            }

            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 2
0
        public ActionResult DOEntry()
        {
            Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1();
            OrderMaster             OM     = new OrderMaster();
            DailyOrder DO          = new DailyOrder();
            var        currentdate = Convert.ToDateTime(DateTime.Now.ToShortDateString());

            var orderdetails = Entity.OrderMasters.Where(q => q.StartDate <= currentdate && q.EndDate >= currentdate && (q.Status.Equals("Accept") || q.Status.Equals("Delivered"))).OrderBy(q => q.CustomerMaster.FirstName).ToList();

            //   var cname = orderdetails.OrderBy(q => q.MenuId).ToList();


            if (orderdetails != null)
            {
                foreach (var order in orderdetails.ToList())
                {
                    DO.CustId  = Convert.ToInt32(order.CustomerId);
                    DO.OrderId = Convert.ToInt32(order.OrderId);
                    DO.Date    = DateTime.Now;
                    DO.Status  = "Pending";
                    DO.Code    = 0;

                    Entity.DailyOrders.Add(DO);
                    Entity.SaveChanges();
                }
            }

            return(RedirectToAction("ViewDailyOrder"));
        }
Exemplo n.º 3
0
        public JsonResult UpdateOrderStatus(int id)
        {
            try
            {
                Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1();
                OrderMaster             OM     = new OrderMaster();
                var details = Entity.OrderMasters.Where(q => q.OrderId == id).FirstOrDefault();
                details.Status = "Accept";
                Entity.Entry(details).State = System.Data.Entity.EntityState.Modified;
                Entity.SaveChanges();


                if (details.StartDate.Day <= DateTime.Now.Day && details.EndDate.Day >= DateTime.Now.Day)
                {
                    DailyOrder dor = new DailyOrder();
                    dor.CustId  = details.CustomerId;
                    dor.OrderId = id;
                    dor.Date    = DateTime.Now;
                    dor.Status  = "Pending";
                    dor.Code    = 0;

                    Entity.DailyOrders.Add(dor);
                    Entity.SaveChanges();
                }

                return(Json("Accept", JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json("Error", JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 4
0
        //
        // GET: /Admin/

        public ActionResult Admin()
        {
            try
            {
                if (Session["UserID"] == null)
                {
                    return(RedirectToAction("Index", "Home"));
                }
                var id = Convert.ToInt32(Session["UserID"]);
                Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1();
                DailyOrder DO     = new DailyOrder();
                var        Orders = Entity.DailyOrderData().Where(q => q.Date.Day == DateTime.Now.Day && q.Date.Month == DateTime.Now.Month).OrderBy(q => q.Status).ToList();
                if (Orders.Count != 0)
                {
                    return(View(Orders));
                }
                else
                {
                    return(RedirectToAction("ViewDailyOrder"));
                }
            }

            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 5
0
        public ActionResult CodeRetrival(FormCollection frm)
        {
            var code = Convert.ToString(frm["code"]);

            Chatpata_dabbaEntities1 Entity = new Chatpata_dabbaEntities1();
            DailyOrder DO = new DailyOrder();

            var cid = Convert.ToInt32(Session["UserID"]);

            //   var dbcode = Entity.DailyOrders.Where(q => q.CustId == cid && q.Code == code).Count();
            var dbcode = Entity.DailyStatusChange().LastOrDefault();

            if (dbcode != null)
            {
                //  var dbcode1 = Entity.DailyOrders.Where(q => q.CustId == cid && q.Code == code).ToList();
                //   var orderstatus=Entity.
                // dbcode1[0].Status = "Delivered";
                var orderdetails = Entity.DailyOrders.Where(q => q.Date.Day == DateTime.Now.Day && q.Date.Month == DateTime.Now.Month).ToList();

                var data = orderdetails.Where(q => Convert.ToDecimal(q.Code) == Convert.ToDecimal(dbcode.rcode) && q.OrderId == dbcode.OrderId).ToList();

                // var orderdetails = Entity.DailyOrderData().Where(q => q.CustId == dbcode.CustId).FirstOrDefault();
                //var orderchange = Entity.DailyOrders.Where(q => q.CustId == orderdetails.CustId).ToList();
                data[0].Status = "Delivered";
                Entity.Entry(data[0]).State = System.Data.Entity.EntityState.Modified;
                Entity.SaveChanges();
                return(RedirectToAction("ThankYouPage"));
            }
            else
            {
                return(RedirectToAction("CodeRetrival"));
            }
        }
Exemplo n.º 6
0
        public JsonResult CancelOrder(int oid)
        {
            try
            {
                Chatpata_dabbaEntities1 en = new Chatpata_dabbaEntities1();
                var currentTime            = Convert.ToDateTime(DateTime.Now.ToShortTimeString());
                var time = Convert.ToDateTime("10:00:00 AM");
                var id   = Convert.ToInt32(Session["UserID"]);

                if (currentTime < time)
                {
                    OrderMaster om      = new OrderMaster();
                    var         ss      = en.OrderMasters.Where(q => q.OrderId == oid && q.CustomerId == id).FirstOrDefault();
                    DailyOrder  Do      = new DailyOrder();
                    var         details = en.DailyOrders.Where(q => q.OrderId == oid && q.CustId == id && q.Date.Day == DateTime.Now.Day && q.Date.Month == DateTime.Now.Month).ToList();
                    details[0].Status = "Cancel";

                    if (ss.PaymentMode == "Online")
                    {
                        decimal[] rid = (en.OrderList().Where(q => q.OrderId == oid).Select(q => q.Price)).ToArray();
                        decimal   r   = Convert.ToDecimal((((rid[0]) * 10) / 100) + rid[0]);
                        ss.Ecoupon = r;
                        en.Entry(details).State = System.Data.Entity.EntityState.Modified;
                        en.SaveChanges();
                    }

                    en.Entry(details[0]).State = System.Data.Entity.EntityState.Modified;
                    en.SaveChanges();
                    return(Json("Cancel", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json("Error", JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception e)
            {
                return(Json("Error", JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 7
0
        public HomePage(Response response) : base(response)
        {
            var xs = response.XPath();

            if (IsOrganization)
            {
                return;
            }

            var script = xs.FindAll("//script")
                         .First(n => n.Extract().Trim().StartsWith("var erepublik"))
                         .Extract()
                         .Split('\n')
                         .Select(l => l.Trim().TrimEnd(',')).ToList();

            var dailyTasksDone      = script.First(l => l.StartsWith("dailyTasksDone")).EndsWith("true");
            var dailyOrderDone      = script.First(l => l.StartsWith("dailyOrderDone")).EndsWith("true");
            var hasDailyTasksReward = script.First(l => l.StartsWith("hasReward")).EndsWith("true");
            var hasDailyOrderReward = script.First(l => l.StartsWith("hasDailyOrderReward")).EndsWith("true");

            var scriptMap = xs.FindAll("//script")
                            .First(n => n.Extract().Trim().StartsWith("var mapSettings"))
                            .Extract();

            var doJson  = Regex.Match(scriptMap, @"var mapDailyOrder\s*=\s*(.+?);").Groups[1].Value;
            var doModel = JsonConvert.DeserializeObject <DailyOrderJson>(doJson);

            DailyOrder = new DailyOrder
            {
                CampaignId      = doModel.CampaignId,
                RegionName      = doModel.RegionName,
                Done            = dailyOrderDone,
                RewardCollected = hasDailyOrderReward,
                KillsCompleted  = doModel.KillsProgress,
                KillsTotal      = doModel.KillsTarget
            };

            DailyRewardAvailable = dailyTasksDone && !hasDailyTasksReward;
        }