public ActionResult Welcome(string id)
        {
            DeliveryTeam sp = new DeliveryTeam();

            sp.DelivererId = db.DeliveryTeams.FirstOrDefault(x => x.Id.Equals(id)).DelivererId;
            return(View(sp));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            DeliveryTeam deliveryTeam = db.DeliveryTeams.Find(id);

            db.DeliveryTeams.Remove(deliveryTeam);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "DelivererId,Id,Name")] DeliveryTeam deliveryTeam)
 {
     if (ModelState.IsValid)
     {
         db.Entry(deliveryTeam).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(deliveryTeam));
 }
        public ActionResult Create([Bind(Include = "DelivererId,Id,Name")] DeliveryTeam deliveryTeam)
        {
            if (ModelState.IsValid)
            {
                db.DeliveryTeams.Add(deliveryTeam);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(deliveryTeam));
        }
        // GET: DeliveryTeams/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DeliveryTeam deliveryTeam = db.DeliveryTeams.Find(id);

            if (deliveryTeam == null)
            {
                return(HttpNotFound());
            }
            return(View(deliveryTeam));
        }
        public ActionResult PassOrderr(int id)
        {
            List <DeliveryTeam> list = new List <DeliveryTeam>();
            DeliveryTeam        c    = new DeliveryTeam();
            AssignOrder         cat  = db.AssignOrders.Find(id);

            if (cat != null)
            {
                ViewBag.msg = "This order has been assigned";
                return(RedirectToAction("ViewOrders", "Admin"));
            }
            TempData["id"] = id;
            return(RedirectToAction("Index2", "Admin"));
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.FName, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    if (model.roles == "Customer")
                    {
                        DB22Entities3 db1 = new DB22Entities3();
                        Customer      cus = new Customer();
                        cus.Address = model.address;
                        cus.Id      = user.Id;
                        cus.Name    = model.FName;
                        db1.Customers.Add(cus);
                        db1.SaveChanges();
                        await UserManager.AddToRoleAsync(user.Id, "Customer");

                        db1.SaveChanges();
                        return(RedirectToAction("Welcome", "Customers", new { id = user.Id }));
                    }
                    else if (model.roles == "Chef")
                    {
                        DB22Entities3 db1 = new DB22Entities3();
                        Chef          che = new Chef();
                        che.Id   = user.Id;
                        che.Name = model.FName;
                        db1.Chefs.Add(che);
                        db1.SaveChanges();

                        await UserManager.AddToRoleAsync(user.Id, "Chef");

                        //db1.SaveChanges();
                        return(RedirectToAction("Welcome", "Chefs", new { id = user.Id }));
                    }

                    else if (model.roles == "Supplier")
                    {
                        DB22Entities3 db1 = new DB22Entities3();
                        Supplier      che = new Supplier();
                        che.Id   = user.Id;
                        che.Name = model.FName;
                        db1.Suppliers.Add(che);
                        db1.SaveChanges();
                        await UserManager.AddToRoleAsync(user.Id, "Supplier");

                        //db1.SaveChanges();

                        return(RedirectToAction("Welcome", "Suppliers"));
                    }

                    else if (model.roles == "Delivery")
                    {
                        DB22Entities3 db1 = new DB22Entities3();
                        DeliveryTeam  che = new DeliveryTeam();
                        che.Id   = user.Id;
                        che.Name = model.FName;
                        db1.DeliveryTeams.Add(che);
                        db1.SaveChanges();
                        await UserManager.AddToRoleAsync(user.Id, "Delivery");

                        //db1.SaveChanges();
                        return(RedirectToAction("Welcome", "DeliveryTeam", new { id = user.Id }));
                    }
                    else
                    {
                        return(View(model));
                    }
                }

                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.FName, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    if (model.roles == "Customer")
                    {
                        DB22Entities3 db1 = new DB22Entities3();
                        Customer      cus = new Customer();
                        cus.Address = model.address;
                        cus.Id      = user.Id;
                        cus.Name    = model.FName;
                        db1.Customers.Add(cus);
                        db1.SaveChanges();
                        await UserManager.AddToRoleAsync(user.Id, "Customer");

                        db1.SaveChanges();
                        return(RedirectToAction("Index", "Home"));
                    }
                    else if (model.roles == "Chef")
                    {
                        DB22Entities3 db1 = new DB22Entities3();
                        Chef          che = new Chef();
                        che.Id   = user.Id;
                        che.Name = model.FName;
                        db1.Chefs.Add(che);
                        try
                        {
                            db1.SaveChanges();
                        }

                        catch (DbEntityValidationException dbEx)
                        {
                            foreach (var validationErrors in dbEx.EntityValidationErrors)
                            {
                                foreach (var validationError in validationErrors.ValidationErrors)
                                {
                                    System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                                }
                            }
                        }
                        await UserManager.AddToRoleAsync(user.Id, "Chef");

                        //db1.SaveChanges();
                        return(RedirectToAction("Index", "Home"));
                    }

                    else if (model.roles == "Supplier")
                    {
                        DB22Entities3 db1 = new DB22Entities3();
                        Supplier      che = new Supplier();
                        che.Id   = user.Id;
                        che.Name = model.FName;
                        db1.Suppliers.Add(che);
                        db1.SaveChanges();
                        await UserManager.AddToRoleAsync(user.Id, "Supplier");

                        return(RedirectToAction("Welcome", "Suppliers", new { id = user.Id }));
                    }

                    else if (model.roles == "Delivery")
                    {
                        DB22Entities3 db1 = new DB22Entities3();
                        DeliveryTeam  che = new DeliveryTeam();
                        che.Id   = user.Id;
                        che.Name = model.FName;
                        db1.DeliveryTeams.Add(che);
                        db1.SaveChanges();
                        await UserManager.AddToRoleAsync(user.Id, "Delivery");

                        //db1.SaveChanges();
                        return(RedirectToAction("Index", "Home"));
                    }
                    else
                    {
                        return(View(model));
                    }
                }

                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }