public ActionResult Create([Bind(Include = "Sum_Id,Product_Id,Product_Id2,Product_Id3")] SumCargo sumCargo)
        {
            if (ModelState.IsValid)
            {
                db.SumCargoes.Add(sumCargo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Product_Id  = new SelectList(db.Pets, "Pet_Id", "Name", sumCargo.Product_Id);
            ViewBag.Product_Id2 = new SelectList(db.Products, "Product_Id", "Name", sumCargo.Product_Id2);
            ViewBag.Product_Id3 = new SelectList(db.Trainers, "Trainer_Id", "Name", sumCargo.Product_Id3);
            return(View(sumCargo));
        }
 public ActionResult Registers(RegisterViewModel model, FormCollection fc)
 {
     try
     {
         string   date = fc["Birthdate"];
         customer cus  = new customer();
         cus.Username        = fc["Username"];
         cus.Password        = fc["Password"];
         cus.ConfirmPassword = fc["ConfirmPassword"];
         cus.E_mail          = fc["E_mail"];
         cus.Fullname        = fc["Fullname"];
         cus.Sex             = fc["Sex"];
         cus.Birthdate       = Convert.ToDateTime(date);
         cus.Phone_No        = fc["Phone_No"];
         cus.Address         = fc["Address"];
         cus.UserType        = "User";
         Re.customers.Add(cus);
         Re.SaveChanges();
     }
     catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
     {
         Exception raise = dbEx;
         foreach (var validationErrors in dbEx.EntityValidationErrors)
         {
             foreach (var validationError in validationErrors.ValidationErrors)
             {
                 string message = string.Format("{0}:{1}",
                                                validationErrors.Entry.Entity.ToString(),
                                                validationError.ErrorMessage);
                 // raise a new exception nesting
                 // the current instance as InnerException
                 raise = new InvalidOperationException(message, raise);
             }
         }
         throw raise;
     }
     return(View("Conditiontwo"));
 }
Beispiel #3
0
        public ActionResult RateVote(int id, FormCollection fc)
        {
            int        ss         = Convert.ToInt16(fc["rate"]);
            PeviewStar PeviewStar = new PeviewStar();

            PeviewStar.Customer_id = id;
            PeviewStar.Score       = ss;
            pe.PeviewStars.Add(PeviewStar);
            pe.SaveChanges();


            ViewData["Shop"] = pe.customers.Where(a => a.Customer_Id == id).Single();
            return(View("Shop", new { id = id }));
        }
Beispiel #4
0
        public ActionResult CreatePet(int id, FormCollection fc)
        {
            try
            {
                string date  = fc["Birthdate"];
                string Price = fc["Price"];
                Pet    pet   = new Pet();
                if (ModelState.IsValid)
                {
                    var file = Request.Files[0];
                    if (file != null && file.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(file.FileName);
                        var path     = Path.Combine(Server.MapPath("~/Content/images/images_pet"), fileName);
                        file.SaveAs(path);
                        pet.Images = fileName;
                    }
                }
                pet.Name        = fc["Name"];
                pet.Customer_id = id;
                pet.Price       = Convert.ToDecimal(Price);
                pet.Sex         = fc["Sex"];
                pet.Birthdate   = Convert.ToDateTime(date);
                pet.Gene        = fc["Gene"];
                pet.History     = fc["History"];
                pet.Typess      = fc["Type"];
                Cp.Pets.Add(pet);
                Cp.SaveChanges();
                Session["id"] = pet.Pet_Id;
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        // raise a new exception nesting
                        // the current instance as InnerException
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }

            return(View("Addpic"));
        }
        public ActionResult UpdateUserdata(int id, FormCollection fc)
        {
            int a = 0;

            try
            {
                customer cus = Ad.customers.Where(c => c.Customer_Id == id).Single();

                if (cus.Shop_name == null)
                {
                    a = 1;
                    ViewBag.listProduct = Ad.customers.ToList();
                    cus.E_mail          = fc["Email"];
                    cus.Username        = fc["Username"];
                    cus.Fullname        = fc["Fullname"];
                    cus.Phone_No        = fc["Tel"];
                    cus.Address         = fc["Address"];
                    Ad.SaveChanges();
                }
                else
                {
                    ViewBag.listProduct = Ad.customers.Where(c => c.Shop_name != null).ToList();
                    cus.E_mail          = fc["Email"];
                    cus.Username        = fc["Username"];
                    cus.Fullname        = fc["Fullname"];
                    cus.Phone_No        = fc["Tel"];
                    cus.Address         = fc["Address"];
                    cus.Shop_name       = fc["Shop_name"];
                    cus.Name_Bank       = fc["Bank_Name"];
                    cus.Name_Owner      = fc["Bank_NameOwner"];
                    cus.Id_Bank         = fc["Bank_No"];
                    cus.Card_No         = fc["Credit_No"];
                    Ad.SaveChanges();
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }



            ViewData["ShowDataUser"] = Ad.customers.Where(c => c.Customer_Id == id).Single();
            Session["ShowDataUser"]  = "******";

            if (a == 1)
            {
                return(View("User"));
            }
            else
            {
                return(View("Shop"));
            }
        }
Beispiel #6
0
        public ActionResult Save_Order(FormCollection fc)
        {
            int     id = 0;
            decimal a = 2500, b = 3000, c = 2000, d = 3500, e = 6000;

            if (fc["Delivery"] == "2")
            {
                Session["price_send"] = a;
            }
            else if (fc["Delivery"] == "3")
            {
                Session["price_send"] = b;
            }
            else if (fc["Delivery"] == "4")
            {
                Session["price_send"] = c;
            }
            else if (fc["Delivery"] == "5")
            {
                Session["price_send"] = c;
            }
            else if (fc["Delivery"] == "6")
            {
                Session["price_send"] = d;
            }
            else
            {
                Session["price_send"] = e;
            }

            List <item> items   = (List <item>)Session["cart"];
            decimal     summary = 0;

            try
            {
                Order orders = new Order();
                orders.Grand_total  = Convert.ToDecimal(Session["Grand_Total"]);
                orders.Customer_Id  = Convert.ToInt32(Session["UserID"]);
                orders.Card_No      = fc["Pay"];
                orders.Card_Name    = fc["Delivery"];
                orders.Order_date   = DateTime.Now;
                orders.Order_status = "New";
                pe.Orders.Add(orders);
                pe.SaveChanges();
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }

            try
            {
                foreach (item it in items)
                {
                    if (it.Pet.Pet_Id != null || it.Product.Product_Id != null || it.Trainer.Trainer_Id != null)
                    {
                        if (it.Pet.Pet_Id >= 1 && it.Pet.Pet_Id <= 39999)
                        {
                            id = it.Pet.Pet_Id;
                        }
                        else if (it.Product.Product_Id >= 40000 && it.Product.Product_Id <= 99500)
                        {
                            id = it.Product.Product_Id;
                        }
                        else if (it.Trainer.Trainer_Id >= 99500 && it.Trainer.Trainer_Id <= 110000)
                        {
                            id = it.Trainer.Trainer_Id;
                        }
                        else
                        {
                        }
                    }
                    if (id >= 1 && id <= 39999)
                    {
                        Orders_Details od = new Orders_Details();
                        od.Order_Id   = pe.Orders.Max(item => item.Order_Id);
                        od.Product_Id = it.Pet.Pet_Id;
                        od.Amount     = it.Quantity;
                        od.Sub_total  = (it.Pet.Price * it.Quantity);
                        pe.Orders_Details.Add(od);
                        pe.SaveChanges();
                    }
                    else if (id >= 40000 && id < 99500)
                    {
                        Orders_Details od = new Orders_Details();
                        od.Order_Id    = pe.Orders.Max(item => item.Order_Id);
                        od.Product_Id2 = it.Product.Product_Id;
                        od.Amount      = it.QuantityProduct;
                        od.Sub_total   = (it.Product.Price * it.QuantityProduct);
                        pe.Orders_Details.Add(od);
                        pe.SaveChanges();
                    }
                    else if (id >= 99500 && id < 110000)
                    {
                        Orders_Details od = new Orders_Details();
                        od.Order_Id    = pe.Orders.Max(item => item.Order_Id);
                        od.Product_Id3 = it.Trainer.Trainer_Id;
                        od.Amount      = it.QuantityTrainer;
                        od.Sub_total   = (it.Trainer.Price * it.QuantityTrainer);
                        pe.Orders_Details.Add(od);
                        pe.SaveChanges();
                    }
                    else
                    {
                    }
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
            {
                Exception raise = dbEx;
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        string message = string.Format("{0}:{1}",
                                                       validationErrors.Entry.Entity.ToString(),
                                                       validationError.ErrorMessage);
                        raise = new InvalidOperationException(message, raise);
                    }
                }
                throw raise;
            }

            if (fc["Pay"] == "30")
            {
                Session["Checkdiv"] = "1";
                return(View("AddressInput"));
            }
            else
            {
                return(View("AddressInput"));
            }
        }