Ejemplo n.º 1
0
        public ActionResult OrderHistoryDetails(int id)
        {
            List <OrderHistory_ViewModel> ohvmlist = new List <OrderHistory_ViewModel>();
            var           obj  = db.OrderDetail_Table.Where(x => x.Orderid == id).ToList();
            Service_Table s    = new Service_Table();
            User_Table    uobj = new User_Table();

            foreach (var item in obj)
            {
                var service = db.OrderDetail_Table.Where(x => x.Orderid == id).Select(x => x.Serviceid).FirstOrDefault();
                // var servicename = db.Service_Table.Where(x => x.ServiceId == service).Select(x => x.ServiceName).FirstOrDefault();
                s    = db.Service_Table.Where(x => x.ServiceId == service).FirstOrDefault();
                uobj = db.User_Table.Where(x => x.UserId == s.ServiceProviderid).FirstOrDefault();
                var product_desc            = db.Product_Table.Where(x => x.ProductId == item.Productid).Select(x => x.ProductDesc).FirstOrDefault();
                var product                 = db.Product_Table.Where(x => x.ProductId == item.Productid).Select(x => x.ProductName).FirstOrDefault();
                var deliveryadd             = db.Order_Table.Where(x => x.OrderId == id).Select(x => x.OrderDeliveryAddress).FirstOrDefault();
                var deliverydate            = db.Order_Table.Where(x => x.OrderId == id).Select(x => x.OrderDeliveryDate).FirstOrDefault();
                var image                   = db.Image_Table.Where(x => x.Productid == item.Productid).Select(x => x.BinaryImage).FirstOrDefault();
                OrderHistory_ViewModel obj1 = new OrderHistory_ViewModel();
                obj1.ProductName         = product;
                obj1.ProductDesc         = product_desc;
                obj1.OrderDelivryAddress = deliveryadd;
                obj1.Amount            = (decimal)item.Amount;
                obj1.OrderDeliveryDate = (DateTime)deliverydate;
                obj1.ServiceName       = uobj.UserName;
                obj1.BinaryImage       = image;
                ohvmlist.Add(obj1);
            }


            return(View(ohvmlist));
        }
Ejemplo n.º 2
0
        public ActionResult ServiceDelete(int serviceId)
        {
            Service_Table service = db.Service_Table.Find(serviceId);

            service.ServiceIsDeleted   = true;
            service.ServiceUpdatedBy   = Session["user"].ToString();
            service.ServiceUpdatedDate = System.DateTime.Now;
            db.SaveChanges();
            bool result      = true;
            var  redirectUrl = new UrlHelper(Request.RequestContext).Action("Manage_Service", "Service");

            return(Json(new { Url = redirectUrl, result }));
        }
Ejemplo n.º 3
0
        public ActionResult service_name_all(string id)
        {
            Session["location"] = id;
            List <SelectListItem> ServiceList = new List <SelectListItem>();
            List <Service_Table>  s           = new List <Service_Table>();

            int locId = Convert.ToInt32(id);
            // var ser = db.Service_Table.Where(x => x.Locationid == locId).Select(x => x.ServiceProviderid).ToList();
            var ser    = db.Service_Table.Where(x => x.Locationid == locId).ToList();
            int previd = 0;

            foreach (var items in ser)
            {
                if (previd != items.ServiceProviderid)
                {
                    Service_Table excuseme = db.Service_Table.Where(x => x.ServiceProviderid == items.ServiceProviderid).FirstOrDefault();
                    previd = excuseme.ServiceProviderid;
                    s.Add(excuseme);
                }
            }
            int        total_pro = Convert.ToInt32(TempData["count"]);
            List <int> availid   = TempData["avail"] as List <int>;


            foreach (var item1 in s)
            {
                int count = 0;
                foreach (var item in availid)
                {
                    int           pid = Convert.ToInt32(item);
                    Service_Table obj = db.Service_Table.Where(x => x.Productid == pid & x.ServiceProviderid == item1.ServiceProviderid).FirstOrDefault();
                    if (obj != null)
                    {
                        count++;
                    }
                }
                if (count == total_pro)
                {
                    string     sname = db.Service_Table.Where(x => x.ServiceProviderid == item1.ServiceProviderid).Select(x => x.ServiceName).FirstOrDefault();
                    User_Table uobj  = db.User_Table.Where(x => x.UserId == item1.ServiceProviderid).FirstOrDefault();
                    ServiceList.Add(new SelectListItem
                    {
                        Text  = uobj.UserName,
                        Value = uobj.UserId.ToString(),
                    });
                }
            }


            return(Json(ServiceList, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public ActionResult purchase_all(Book obj)
        {
            string name = Session["user"].ToString();
            int    usid = db.User_Table.Where(x => x.UserName == name).Select(x => x.UserId).FirstOrDefault();

            Order_Table order = db.Order_Table.Where(x => x.OrderStatus == 0 & x.OrderIsDeleted == false & x.Userid == usid).FirstOrDefault();

            order.OrderDeliveryAddress = obj.OrderDelivryAddress;
            order.TotalAmount          = Convert.ToInt32(TempData["tcart_amt"]);
            order.OrderNotification    = "00";
            order.OrderDeliveryDate    = System.DateTime.Now.AddDays(5);
            order.OrderStatus          = 1;
            db.SaveChanges();
            var odetail = db.OrderDetail_Table.Where(x => x.Orderid == order.OrderId).Select(x => x.OrderDetailId).ToList();

            foreach (var item in odetail)
            {
                int               flag     = 0;
                List <int>        availid1 = TempData["avail1"] as List <int>;
                OrderDetail_Table obj1     = db.OrderDetail_Table.Where(x => x.OrderDetailId == item).FirstOrDefault();
                foreach (var pro in availid1)
                {
                    if (obj1.Productid == pro)
                    {
                        Product_Table pobj  = db.Product_Table.Where(x => x.ProductId == pro).FirstOrDefault();
                        int           stock = Convert.ToInt32(pobj.ProductStock);
                        int           qty   = Convert.ToInt32(obj1.Quantity);
                        pobj.ProductStock = stock - qty;
                        db.SaveChanges();
                        flag = 1;
                    }
                }
                if (flag == 1)
                {
                    int           lid    = Convert.ToInt32(Session["location"]);
                    Service_Table serboj = db.Service_Table.Where(x => x.ServiceProviderid == obj.UserId && x.Locationid == lid).FirstOrDefault();
                    obj1.Serviceid = serboj.ServiceId;
                    db.SaveChanges();
                }
                else
                {
                    db.OrderDetail_Table.Remove(obj1);
                    db.SaveChanges();
                }
            }
            count_cart();
            Session["location"] = null;
            return(RedirectToAction("notification"));
        }
Ejemplo n.º 5
0
        public ActionResult Add_Service(Service_ViewModel model, string[] productIds)
        {
            try
            {
                Notification_Count();

                string             name = Session["user"].ToString();
                int                serviceProviderId = db.User_Table.Where(x => x.UserName == name).Select(x => x.UserId).FirstOrDefault();
                List <Order_Table> orderList         = new List <Order_Table>();

                for (int i = 0; i < productIds.Count(); i++)
                {
                    int currentProduct = Convert.ToInt32(productIds[i]);
                    var product        = (from s in db.Service_Table where s.Productid == currentProduct && s.Locationid == model.selectedLocation && s.ServiceProviderid == serviceProviderId && s.ServiceIsDeleted == false select s).FirstOrDefault();

                    if (product == null)
                    {
                        Service_Table service = new Service_Table();
                        service.Locationid         = model.selectedLocation;
                        service.DeliveryCharge     = model.deliveryCharge;
                        service.ServiceDesc        = model.serviceDescription;
                        service.Productid          = Convert.ToInt32(productIds[i]);
                        service.ServiceName        = model.serviceName;
                        service.ServiceProviderid  = serviceProviderId;
                        service.ServiceCreatedDate = System.DateTime.Now;
                        service.ServiceUpdatedDate = System.DateTime.Now;
                        service.ServiceCreatedBy   = Session["user"].ToString();
                        service.ServiceUpdatedBy   = Session["user"].ToString();
                        service.ServiceIsDeleted   = false;
                        db.Service_Table.Add(service);
                        db.SaveChanges();
                    }
                    else
                    {
                        var    productName = (from p in db.Product_Table where p.ProductId == currentProduct select p.ProductName).FirstOrDefault();
                        string message     = String.Format("Same location already added for the product " + productName);
                        TempData["Message"] = message;
                        return(RedirectToAction("Add_Service"));
                    }
                }
                TempData["Message"] = "Service Added";
                return(RedirectToAction("Add_Service"));
            }
            catch (Exception e)
            {
                TempData["Message"] = "fill all fileds";
                return(RedirectToAction("Add_Service"));
            }
        }
Ejemplo n.º 6
0
        public ActionResult order(Book obj, string amt)
        {
            string name  = Session["user"].ToString();
            int    pid   = Convert.ToInt32(Session["pro_id"].ToString());
            int    stock = db.Product_Table.Where(x => x.ProductId == pid).Select(x => x.ProductStock).FirstOrDefault();

            if (obj.Quantity <= stock)
            {
                Order_Table       order        = new Order_Table();
                OrderDetail_Table order_detail = new OrderDetail_Table();
                order.TotalAmount          = Convert.ToInt32(amt);
                order.OrderDeliveryAddress = obj.OrderDelivryAddress;
                order.OrderDeliveryDate    = System.DateTime.Now.AddDays(5);
                order.Userid            = db.User_Table.Where(x => x.UserName == name).Select(x => x.UserId).FirstOrDefault();
                order.OrderCreatedBy    = name;
                order.OrderUpdatedBy    = name;
                order.OrderCreatedDate  = System.DateTime.Now;
                order.OrderUpdatedDate  = System.DateTime.Now;
                order.OrderIsDeleted    = false;
                order.OrderStatus       = 1;
                order.OrderNotification = "00";
                db.Order_Table.Add(order);
                db.SaveChanges();
                int oid = order.OrderId;
                order_detail.Orderid   = oid;
                order_detail.Productid = pid;
                int           lid    = Convert.ToInt32(Session["location"]);
                Service_Table serboj = db.Service_Table.Where(x => x.ServiceProviderid == obj.UserId && x.Locationid == lid).FirstOrDefault();
                order_detail.Serviceid = serboj.ServiceId;
                order_detail.Quantity  = obj.Quantity;
                order_detail.Amount    = Convert.ToInt32(amt);
                db.OrderDetail_Table.Add(order_detail);
                db.SaveChanges();
                Product_Table pobj = db.Product_Table.Where(x => x.ProductId == pid).FirstOrDefault();
                pobj.ProductStock = stock - obj.Quantity;
                db.SaveChanges();
            }
            Session["location"] = null;
            return(RedirectToAction("notification"));
        }
Ejemplo n.º 7
0
        public JsonResult ServiceEdit(int ServiceId, string ServiceName, decimal DeliveryCharge, string ServiceDesc, string LocationName, string ProductName)
        {
            Product_Table  product  = new Product_Table();
            Location_Table location = new Location_Table();
            Service_Table  service  = db.Service_Table.Find(ServiceId);

            service.ServiceName    = ServiceName;
            service.DeliveryCharge = DeliveryCharge;
            service.ServiceDesc    = ServiceDesc;
            int locationId = (from l in db.Location_Table where l.LocationName == LocationName select l.LocationId).FirstOrDefault();

            service.Locationid = locationId;
            int productId = (from p in db.Product_Table where p.ProductName == ProductName select p.ProductId).FirstOrDefault();

            service.Productid          = productId;
            service.ServiceUpdatedBy   = Session["user"].ToString();
            service.ServiceUpdatedDate = System.DateTime.Now;
            db.SaveChanges();
            var redirectUrl = new UrlHelper(Request.RequestContext).Action("Manage_Service", "Service");

            return(Json(new { ServiceId = ServiceId, ServiceName = ServiceName, DeliveryCharge = DeliveryCharge, ServiceDesc = ServiceDesc, LocationName = LocationName, ProductName = ProductName, Url = redirectUrl }, JsonRequestBehavior.AllowGet));
        }