public ActionResult Register(UserAcount account)
        {
            if (ModelState.IsValid)
            {
                using (CCV_Tables_Context db = new CCV_Tables_Context())
                {
                    bool isAlreadyRegistered = db.UserAcounts.Any(c => c.Password == account.Password) && db.UserAcounts.Any(c => c.Username == account.Username);
                    if (!isAlreadyRegistered)
                    {
                        db.UserAcounts.Add(account);
                        db.SaveChanges();
                        ModelState.Clear();
                        TempData["WelcomeUser"] = account.LastName + " " + account.FirstName + " successfully registered";
                        return(RedirectToAction("Login"));
                    }
                    else
                    {
                        TempData["AlreadyExist"] = "Please change your password or username";
                    }
                }
                ViewBag.Message = account.LastName + " " + account.FirstName + " successfully registered";
            }

            return(View());
        }
Beispiel #2
0
 // GET: StoreHouse
 public ActionResult Index()
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         return(View(db.StoreHouses.ToList()));
     }
 }
Beispiel #3
0
        public ActionResult NewShelf(Shelf shelf)
        {
            using (CCV_Tables_Context db = new CCV_Tables_Context())
            {
                if (ModelState.IsValid)
                {
                    bool isAlreadyRegistered = db.Shelves.Any(c => c.Xposition == shelf.Xposition) &&
                                               db.Shelves.Any(c => c.Yposition == shelf.Yposition) &&
                                               db.Shelves.Any(c => c.RackId == shelf.RackId);
                    if (!isAlreadyRegistered)
                    {
                        shelf.RackId = (int)HttpContext.Session["RackID"];
                        db.Shelves.Add(shelf);
                        db.SaveChanges();
                        ModelState.Clear();
                        return(RedirectToAction("Index", new { iD = Session["RackID"] }));
                    }
                    else
                    {
                        TempData["AlreadyExist"] = "You can not create two shelves on the same position";
                    }
                }

                return(View());
            }
        }
 public ActionResult Details(int id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         return(View(db.UserAcounts.SingleOrDefault(c => c.UserId == id)));
     }
 }
 // GET: Account
 public ActionResult Index()
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         return(View(db.UserAcounts.ToList()));
     }
 }
Beispiel #6
0
 public ActionResult Details(int id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         Session["StoreHouseName"] = db.StoreHouses.Where(c => c.StoreHouseId == id).Single().StoreHouseName;
         return(View(db.StoreHouses.SingleOrDefault(c => c.StoreHouseId == id)));
     }
 }
Beispiel #7
0
 public ActionResult Details(int id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         Session["RackName"] = db.Racks.Where(c => c.RackId == id).Single().Xposition + ":" + db.Racks.Where(c => c.RackId == id).Single().Yposition;
         return(View(db.Racks.SingleOrDefault(c => c.RackId == id)));
     }
 }
Beispiel #8
0
 public ActionResult More(int id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         Session["RackName"] = db.Racks.Where(c => c.RackId == id).Single().Xposition + ":" + db.Racks.Where(c => c.RackId == id).Single().Yposition;
         return(RedirectToAction("Index", "Shelf", new { iD = id }));
     }
 }
Beispiel #9
0
 public ActionResult More(int id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         Session["StoreHouseName"] = db.StoreHouses.Where(c => c.StoreHouseId == id).Single().StoreHouseName;
         //TempData["SHId"] = id;
         return(RedirectToAction("Index", "Rack", new { iD = id }));
     }
 }
Beispiel #10
0
 public ActionResult Delete(int id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         var shelf = db.Shelves.SingleOrDefault(c => c.ShelfId == id);
         db.Shelves.Remove(shelf);
         db.SaveChanges();
         return(RedirectToAction("Index", new { iD = Session["RackID"] }));
     }
 }
 public ActionResult Delete(int id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         var emp = db.UserAcounts.SingleOrDefault(c => c.UserId == id);
         db.UserAcounts.Remove(emp);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
Beispiel #12
0
 public ActionResult Delete(int id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         var rack = db.Racks.SingleOrDefault(c => c.RackId == id);
         db.Racks.Remove(rack);
         db.SaveChanges();
         return(RedirectToAction("Index", new { iD = Session["StoreHouseID"] }));
     }
 }
Beispiel #13
0
 public ActionResult Delete(int id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         var stHouse = db.StoreHouses.SingleOrDefault(c => c.StoreHouseId == id);
         db.StoreHouses.Remove(stHouse);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
 }
 public ActionResult Edit(UserAcount account)
 {
     if (ModelState.IsValid)
     {
         using (CCV_Tables_Context db = new CCV_Tables_Context())
         {
             db.Entry(account).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     return(View());
 }
Beispiel #15
0
        public ActionResult Edit(Rack rack)
        {
            using (CCV_Tables_Context db = new CCV_Tables_Context())
            {
                if (ModelState.IsValid)
                {
                    rack.StoreHouseRefId = (int)HttpContext.Session["StoreHouseID"];
                    db.Entry(rack).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index", new{ iD = Session["StoreHouseID"] }));
                }

                return(View());
            }
        }
Beispiel #16
0
        public ActionResult Index(int id)
        {
            Session["StoreHouseID"] = id;
            using (CCV_Tables_Context db = new CCV_Tables_Context())
            {
                Session["StoreHouseName"] = db.StoreHouses.Where(c => c.StoreHouseId == id).Single().StoreHouseName;
                List <Rack> racks = db.Racks.Where(c => c.StoreHouseRefId == id).ToList();
                var         model = new RackModel()
                {
                    Racks = racks, StoreHouseId = id
                };

                return(View(model));
            }
        }
Beispiel #17
0
        public ActionResult Edit(Shelf shelf)
        {
            using (CCV_Tables_Context db = new CCV_Tables_Context())
            {
                if (ModelState.IsValid)
                {
                    shelf.RackId          = (int)HttpContext.Session["RackID"];
                    db.Entry(shelf).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index", new { iD = Session["RackID"] }));
                }

                return(View());
            }
        }
Beispiel #18
0
        public ActionResult Import(HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    if (upload.FileName.EndsWith(".csv"))
                    {
                        Stream    stream   = upload.InputStream;
                        DataTable csvTable = new DataTable();
                        using (CsvReader csvReader =
                                   new CsvReader(new StreamReader(stream), true))
                        {
                            csvTable.Load(csvReader);
                        }

                        using (CCV_Tables_Context db = new CCV_Tables_Context())
                        {
                            string[] words;
                            for (int i = 0; i < csvTable.Rows.Count; i++)
                            {
                                csvTable.Rows[i].ItemArray[0].ToString();
                                words = csvTable.Rows[i].ItemArray[0].ToString().Split(';');
                                Rack rack = new Rack();
                                rack.EAN             = Int32.Parse(words[0]);
                                rack.Xposition       = Int32.Parse(words[1]);
                                rack.Yposition       = Int32.Parse(words[2]);
                                rack.Activ           = Boolean.Parse(words[3]);
                                rack.StoreHouseRefId = (int)Session["StoreHouseID"];
                                db.Racks.Add(rack);
                                db.SaveChanges();
                            }
                        }
                        return(View(csvTable));
                    }
                    else
                    {
                        ModelState.AddModelError("File", "This file format is not supported");
                        return(View());
                    }
                }
                else
                {
                    ModelState.AddModelError("File", "Please Upload Your file");
                }
            }
            return(View());
        }
Beispiel #19
0
        // GET: Shelf
        public ActionResult Index(int id)
        {
            Session["RackID"] = id;
            using (CCV_Tables_Context db = new CCV_Tables_Context())
            {
                Session["RackName"] = db.Racks.Where(c => c.RackId == id).Single().Xposition + ":" + db.Racks.Where(c => c.RackId == id).Single().Yposition;

                List <Shelf> shelves = db.Shelves.Where(c => c.RackId == id).ToList();
                var          model   = new ShelfModel()
                {
                    Shelves = shelves, RackId = id
                };

                return(View(model));
            }
        }
 public ActionResult Edit(int?id)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(BadRequest));
         }
         UserAcount account = db.UserAcounts.Find(id);
         if (User == null)
         {
             return(HttpNotFound());
         }
         return(View(db.UserAcounts.SingleOrDefault(c => c.UserId == id)));
     }
 }
Beispiel #21
0
        public ActionResult Import(HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                if (upload != null && upload.ContentLength > 0)
                {
                    if (upload.FileName.EndsWith(".csv"))
                    {
                        Stream    stream   = upload.InputStream;
                        DataTable csvTable = new DataTable();
                        using (CsvReader csvReader =
                                   new CsvReader(new StreamReader(stream), true))
                        {
                            csvTable.Load(csvReader);
                        }

                        using (CCV_Tables_Context db = new CCV_Tables_Context())
                        {
                            string[] words;
                            for (int i = 0; i < csvTable.Rows.Count; i++)
                            {
                                csvTable.Rows[i].ItemArray[0].ToString();
                                words = csvTable.Rows[i].ItemArray[0].ToString().Split(';');
                                StoreHouse storeHouse = new StoreHouse();
                                storeHouse.StoreHouseName = words[0];
                                StringToEnum myIntToEnum = new StringToEnum();
                                storeHouse.storeHouseType  = myIntToEnum.GetStoreHouseTypeFromString(words[1]);
                                storeHouse.StoreHouseActiv = Boolean.Parse(words[2]);
                                db.StoreHouses.Add(storeHouse);
                                db.SaveChanges();
                            }
                        }
                        return(View(csvTable));
                    }
                    else
                    {
                        ModelState.AddModelError("File", "This file format is not supported");
                        return(View());
                    }
                }
                else
                {
                    ModelState.AddModelError("File", "Please Upload Your file");
                }
            }
            return(View());
        }
Beispiel #22
0
        public ActionResult Edit(int?id)
        {
            using (CCV_Tables_Context db = new CCV_Tables_Context())
            {
                Session["RackName"] = db.Racks.Where(c => c.RackId == id).Single().Xposition + ":" + db.Racks.Where(c => c.RackId == id).Single().Yposition;
                if (id == null)
                {
                    return(new HttpStatusCodeResult(BadRequest));
                }
                Rack rack = db.Racks.Find(id);
                if (rack == null)
                {
                    return(HttpNotFound());
                }

                return(View(db.Racks.SingleOrDefault(c => c.RackId == id)));
            }
        }
Beispiel #23
0
        public ActionResult Edit(int?id)
        {
            using (CCV_Tables_Context db = new CCV_Tables_Context())
            {
                Session["StoreHouseName"] = db.StoreHouses.Where(c => c.StoreHouseId == id).Single().StoreHouseName;
                if (id == null)
                {
                    return(new HttpStatusCodeResult(BadRequest));
                }
                StoreHouse account = db.StoreHouses.Find(id);
                if (User == null)
                {
                    return(HttpNotFound());
                }

                return(View(db.StoreHouses.SingleOrDefault(c => c.StoreHouseId == id)));
            }
        }
        public ActionResult Login(UserAcount user)
        {
            using (CCV_Tables_Context db = new CCV_Tables_Context())
            {
                bool validEmail    = db.UserAcounts.Any(x => x.Username == user.Username);
                bool validPassword = db.UserAcounts.Any(x => x.Password == user.Password);

                if (!validEmail)
                {
                    TempData["alertMessage"] = "Wrong username or password";
                    return(RedirectToAction("Login"));
                }

                if (!validPassword)
                {
                    TempData["alertMessage"] = "Wrong username or password";
                    return(RedirectToAction("Login"));
                }

                var usr = db.UserAcounts.Single(u => u.Username == user.Username && u.Password == user.Password);
                if (usr != null)
                {
                    Session["UserID"]    = usr.UserId.ToString();
                    Session["FirstName"] = usr.FirstName.ToString();
                    bool admin = (usr.UserId == 1);
                    if (admin)
                    {
                        Session["IsAdmin"] = true;
                        return(RedirectToAction("Index"));
                    }
                    return(RedirectToAction("LoggedIn"));
                }
                else
                {
                    ModelState.AddModelError("", "Ussername or Password is wrong");
                }
            }

            return(View());
        }
Beispiel #25
0
 public ActionResult NewRack(Rack rack)
 {
     using (CCV_Tables_Context db = new CCV_Tables_Context())
     {
         if (ModelState.IsValid)
         {
             bool isAlreadyRegistered = db.Racks.Any(c => c.Xposition == rack.Xposition) && db.Racks.Any(c => c.Yposition == rack.Yposition) && db.Racks.Any(c => c.StoreHouseRefId == rack.StoreHouseRefId);
             if (!isAlreadyRegistered)
             {
                 rack.StoreHouseRefId = (int)HttpContext.Session["StoreHouseID"];
                 db.Racks.Add(rack);
                 db.SaveChanges();
                 ModelState.Clear();
                 return(RedirectToAction("Index", new { iD = Session["StoreHouseID"] }));
             }
             else
             {
                 TempData["AlreadyExist"] = "You can not have two rack on the same position";
             }
         }
         return(View());
     }
 }
Beispiel #26
0
        public ActionResult NewStoreHouse(StoreHouse storeHouse)
        {
            using (CCV_Tables_Context db = new CCV_Tables_Context())
            {
                bool isAlreadyRegistered = db.StoreHouses.Any(c => c.StoreHouseName == storeHouse.StoreHouseName);
                if (ModelState.IsValid)
                {
                    if (!isAlreadyRegistered)
                    {
                        db.StoreHouses.Add(storeHouse);
                        db.SaveChanges();
                        ModelState.Clear();
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        TempData["AlreadyExist"] = "There can not be two storehouses with same name";
                    }
                }

                return(View());
            }
        }