예제 #1
0
        public ActionResult Edit(AdminViewModel collection)
        {
            try
            {
                // TODO: Add update logic here
                DBZipShipEntities db = new DBZipShipEntities();
                var admin            = db.Admins.First();
                admin.Name     = collection.Name;
                admin.CNIC     = collection.CNIC;
                admin.Address  = collection.Address;
                admin.Phone    = collection.PhoneNumber;
                admin.Email    = collection.Email;
                admin.Password = collection.Password;
                db.SaveChanges();

                var user = db.Admins.First();

                string message = "Your Information is Updated Successfully " + user.Name;
                return(RedirectToAction("Index", "Order", new { Message = message }));
            }
            catch
            {
                return(View());
            }
        }
예제 #2
0
        public ActionResult Create(TripViewModel collection)
        {
            try
            {
                // TODO: Add insert logic here
                DBZipShipEntities db = new DBZipShipEntities();
                Trip trip            = new Trip();
                trip.Country = collection.Country;
                trip.City    = collection.City;
                trip.Date    = collection.Date;
                trip.AddedBy = User.Identity.GetUserId();
                trip.AddedOn = DateTime.Now.Date;
                db.Trips.Add(trip);
                db.SaveChanges();
                string id   = User.Identity.GetUserId();
                var    user = db.AspNetUsers.Where(x => x.Id == id).First();

                string message = "Your Trip is Added Successfully " + user.Name;
                return(RedirectToAction("Index", "Trips", new { Message = message }));
            }
            catch
            {
                return(View());
            }
        }
예제 #3
0
        public ActionResult DeleteOrder(int id, OrderViewModel collection)
        {
            // TODO: Add delete logic here
            DBZipShipEntities db = new DBZipShipEntities();
            var order            = db.Orders.Where(x => x.Id == id).First();

            db.Entry(order).State = System.Data.Entity.EntityState.Deleted;
            db.SaveChanges();
            string message = "Your Order is Deleted";

            return(RedirectToAction("Index", "Order", new { Message = message }));
        }
예제 #4
0
        public ActionResult Edit(int id, OrderViewModel collection)
        {
            // TODO: Add update logic here
            try
            {
                DBZipShipEntities db     = new DBZipShipEntities();
                OrderViewModel    user   = new OrderViewModel();
                string            userid = User.Identity.GetUserId();


                if (collection.Image != null)
                {
                    string filename = Path.GetFileNameWithoutExtension(collection.Image.FileName);
                    string ext      = Path.GetExtension(collection.Image.FileName);
                    filename = filename + DateTime.Now.Millisecond.ToString();
                    filename = filename + ext;
                    string filetodb = "/Image/" + filename;
                    filename = Path.Combine(Server.MapPath("~/Image/"), filename);
                    collection.Image.SaveAs(filename);
                    collection.ImagePath = filetodb;
                }
                else
                {
                    collection.ImagePath = "/Content/Images/recentorder.png";
                }

                var    curruser = db.AspNetUsers.Where(x => x.Id == userid).First();
                string name     = curruser.Name;
                foreach (Order p in db.Orders)
                {
                    if (p.Id == id)
                    {
                        p.Name      = collection.Name;
                        p.Quantity  = collection.Quantity;
                        p.Price     = Convert.ToInt16(collection.Price);
                        p.DealPrice = Convert.ToInt16(collection.DealPrice);
                        p.ImagePath = collection.ImagePath;
                        p.Brand     = collection.Brand;
                        p.Country   = collection.Country;
                        break;
                    }
                }
                db.SaveChanges();
                string message = "Your Order is Updated Successfully " + name;
                return(RedirectToAction("Index", "Order", new { Message = message }));
            }
            catch
            {
                return(View());
            }
        }
예제 #5
0
        public ActionResult Delete(UserViewModel collection)
        {
            // TODO: Add delete logic here
            DBZipShipEntities db = new DBZipShipEntities();
            string            id = User.Identity.GetUserId();
            var orders           = db.Orders.Where(x => x.AddedBy == id).ToList();

            foreach (var i in orders)
            {
                db.Entry(i).State = System.Data.Entity.EntityState.Deleted;
            }

            db.SaveChanges();
            var trips = db.Trips.Where(x => x.AddedBy == id).ToList();

            foreach (var i in trips)
            {
                db.Entry(i).State = System.Data.Entity.EntityState.Deleted;
            }
            db.SaveChanges();

            /*var reviews = db.Reviews.Where(x => x.AddedBy == id).ToList();
             * foreach (var i in reviews)
             * {
             *  db.Entry(i).State = System.Data.Entity.EntityState.Deleted;
             * }*/
            db.SaveChanges();
            var user = db.AspNetUsers.Where(x => x.Id == id).First();

            db.Entry(user).State = System.Data.Entity.EntityState.Deleted;
            db.SaveChanges();
            AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
            string message = "Your Account is Deleted" + user.Name;

            return(RedirectToAction("Index", "Account", new { Message = message }));
        }
예제 #6
0
        // POST: Order/Select/5

        public ActionResult Select(int id, OrderViewModel collection)
        {
            DBZipShipEntities db = new DBZipShipEntities();
            var s = db.Orders.Where(x => x.Id == id).First();

            s.Status = "Selected";
            Deal d = new Deal();

            d.OrderId    = id;
            d.SelectedBy = User.Identity.GetUserId();
            db.Deals.Add(d);
            db.SaveChanges();
            string message = "Your Order is Selected";

            return(RedirectToAction("Index", "Order", new { Message = message }));
        }
예제 #7
0
        public ActionResult Create(OrderViewModel collection)
        {
            try
            {
                // TODO: Add insert logic here
                DBZipShipEntities db = new DBZipShipEntities();
                string            id = User.Identity.GetUserId();

                var    user = db.AspNetUsers.Where(x => x.Id == id).First();
                string name = user.Name;
                Order  o    = new Order();
                if (collection.Image != null)
                {
                    string filename = Path.GetFileNameWithoutExtension(collection.Image.FileName);
                    string ext      = Path.GetExtension(collection.Image.FileName);
                    filename = filename + DateTime.Now.Millisecond.ToString();
                    filename = filename + ext;
                    string filetodb = "/Image/" + filename;
                    filename = Path.Combine(Server.MapPath("~/Image/"), filename);
                    collection.Image.SaveAs(filename);
                    collection.ImagePath = filetodb;
                }
                else
                {
                    collection.ImagePath = "/Content/Images/recentorder.png";
                }
                o.Name      = collection.Name;
                o.Quantity  = collection.Quantity;
                o.Price     = Convert.ToInt64(collection.Price);
                o.DealPrice = Convert.ToInt64(collection.DealPrice);
                o.AddedBy   = User.Identity.GetUserId();
                o.AddedOn   = DateTime.Now.Date;
                o.ImagePath = collection.ImagePath;
                o.Country   = collection.Country;
                o.Brand     = collection.Brand;
                db.Orders.Add(o);
                db.SaveChanges();
                string message = "Your Order is Created Successfully " + name;

                return(RedirectToAction("Index", "Order", new { Message = message }));
            }
            catch
            {
                return(View());
            }
        }
예제 #8
0
        public ActionResult Edit(RegisterViewModel collection)
        {
            // TODO: Add update logic here
            if (collection.Image != null)
            {
                string filename = Path.GetFileNameWithoutExtension(collection.Image.FileName);
                string ext      = Path.GetExtension(collection.Image.FileName);
                filename = filename + DateTime.Now.Millisecond.ToString();
                filename = filename + ext;
                string filetodb = "/Image/" + filename;
                filename = Path.Combine(Server.MapPath("~/Image/"), filename);
                collection.Image.SaveAs(filename);
                collection.ImagePath = filetodb;
            }
            else
            {
                collection.ImagePath = "/Content/Images/user.png";
            }

            string            id   = User.Identity.GetUserId();
            string            name = "";
            DBZipShipEntities db   = new DBZipShipEntities();
            UserViewModel     user = new UserViewModel();


            foreach (AspNetUser p in db.AspNetUsers)
            {
                if (p.Id == id)
                {
                    p.Name        = collection.Name;
                    p.Email       = collection.Email;
                    p.Address     = collection.Address;
                    p.CNIC        = collection.CNIC;
                    p.PhoneNumber = collection.PhoneNumber;
                    p.UserName    = collection.Email;
                    p.ImagePath   = collection.ImagePath;
                    name          = collection.Name;
                    break;
                }
            }
            db.SaveChanges();
            string message = "Welcome to your account " + name;

            return(RedirectToAction("Index", "Account", new { Message = message }));
        }
예제 #9
0
 public ActionResult Delete(int id, FormCollection collection)  //Delete for Deal
 {
     try
     {
         // TODO: Add delete logic here
         DBZipShipEntities db = new DBZipShipEntities();
         var order            = db.Deals.Where(x => x.OrderId == id).First();
         db.Entry(order).State = System.Data.Entity.EntityState.Deleted;
         var s = db.Orders.Where(x => x.Id == id).First();
         s.Status = null;
         db.SaveChanges();
         string message = "Your Deal is Deleted";
         return(RedirectToAction("Index", "Order", new { Message = message }));
     }
     catch
     {
         return(View());
     }
 }
예제 #10
0
        public ActionResult Delete(int id, TripViewModel collection)
        {
            try
            {
                // TODO: Add delete logic here
                DBZipShipEntities db = new DBZipShipEntities();
                var det = db.Trips.Where(x => x.Id == id).First();
                db.Entry(det).State = System.Data.Entity.EntityState.Deleted;
                db.SaveChanges();
                string iduser = User.Identity.GetUserId();
                var    user   = db.AspNetUsers.Where(x => x.Id == iduser).First();

                string message = "Your Trip is Deleted Successfully " + user.Name;
                return(RedirectToAction("Index", "Trips", new { Message = message }));
            }
            catch
            {
                return(View());
            }
        }
예제 #11
0
        public ActionResult ChangeImage(ImageViewModel collection)
        {
            string filename = Path.GetFileNameWithoutExtension(collection.Image.FileName);
            string ext      = Path.GetExtension(collection.Image.FileName);

            filename = filename + DateTime.Now.Millisecond.ToString();
            filename = filename + ext;
            string filetodb = "/Image/" + filename;

            filename = Path.Combine(Server.MapPath("~/Image/"), filename);
            collection.Image.SaveAs(filename);
            DBZipShipEntities db = new DBZipShipEntities();
            string            id = User.Identity.GetUserId();
            var user             = db.AspNetUsers.Where(x => x.Id == id).First();

            user.ImagePath = filetodb;
            db.SaveChanges();
            string message = "Your Picture is Updated " + user.Name;

            return(RedirectToAction("Index", "Account", new { Message = message }));
        }
예제 #12
0
        public ActionResult Edit(int id, TripViewModel collection)
        {
            try
            {
                // TODO: Add update logic here
                DBZipShipEntities db = new DBZipShipEntities();
                var det = db.Trips.Where(x => x.Id == id).First();
                det.Country = collection.Country;
                det.City    = collection.City;
                det.Date    = Convert.ToDateTime(collection.Date);
                db.SaveChanges();
                string iduser = User.Identity.GetUserId();
                var    user   = db.AspNetUsers.Where(x => x.Id == iduser).First();

                string message = "Your Trip is Updated Successfully " + user.Name;
                return(RedirectToAction("Index", "Trips", new { Message = message }));
            }
            catch
            {
                return(View());
            }
        }
예제 #13
0
        public ActionResult Select(int id)
        {
            DBZipShipEntities db = new DBZipShipEntities();
            var    order         = db.Orders.Where(x => x.Id == id).First();
            string shopperid     = order.AddedBy;
            var    shopper       = db.AspNetUsers.Where(x => x.Id == shopperid).First();

            order.Status = "Deleivered";
            CompletedOrder comorder  = new CompletedOrder();
            var            deal      = db.Deals.Where(x => x.OrderId == order.Id).First();
            var            traveller = db.AspNetUsers.Where(x => x.Id == deal.SelectedBy).First();

            comorder.OrderName     = order.Name;
            comorder.OrderCountry  = order.Country;
            comorder.ShopperName   = shopper.Name;
            comorder.TravellerName = traveller.Name;
            comorder.ImagePath     = order.ImagePath;
            comorder.TravellerId   = traveller.Id;
            comorder.ShopperId     = shopper.Id;
            db.CompletedOrders.Add(comorder);

            var    admin    = db.Admins.First();
            long   p        = Convert.ToInt16(order.DealPrice - order.Price);
            double earnings = Convert.ToDouble((0.07 * order.Price) + (0.07 * p));

            admin.Earnings = Convert.ToInt16(admin.Earnings + earnings);

            string message = "Deal Between" + traveller.Name + " and " + shopper.Name + " is Completed! " + earnings + " Rs is added to ZipShip Earnings";

            db.Entry(order).State = System.Data.Entity.EntityState.Deleted;
            db.Entry(deal).State  = System.Data.Entity.EntityState.Deleted;

            db.SaveChanges();

            return(RedirectToAction("Index", "Order", new { Message = message }));
        }
예제 #14
0
        public ActionResult Review(ReviewViewModel collection)
        {
            if (collection.Review != null)
            {
                DBZipShipEntities db = new DBZipShipEntities();
                string            id = User.Identity.GetUserId();

                var    user = db.AspNetUsers.Where(x => x.Id == id).First();
                string name = user.Name;
                Review r    = new Review();
                r.Review1   = collection.Review;
                r.Name      = user.Name;
                r.ImagePath = user.ImagePath;
                db.Reviews.Add(r);
                db.SaveChanges();
                string message = "Your Review is Added " + name;

                return(RedirectToAction("Index", "Account", new { Message = message }));
            }
            else
            {
                return(View());
            }
        }