Ejemplo n.º 1
0
        public ActionResult Register(UserAccount account)
        {
            bool success = false;

            ConsignmentBusinessLayer db = new ConsignmentBusinessLayer();

            if (db.getUsers(account.signUp.UserName, account.signUp.Email).Tables[0].Rows.Count > 0)
            {
                ModelState.AddModelError("keyName2", "Username or Email Already Taken.");
            }
            else
            {
                UserAccount useracc = new UserAccount();
                useracc.Name     = account.signUp.Name;
                useracc.UserName = account.signUp.UserName;

                useracc.Email = account.signUp.Email;
                useracc.Role  = account.signUp.Role;
                success       = true;

                TempData["SignupStepOne"] = useracc;


/**
 *
 *                  ConsignmentBusinessLayer cbl = new ConsignmentBusinessLayer();
 *                  cbl.addAccount(useracc);
 *
 *
 *
 *
 *                      ViewBag.Message = account.signUp.UserName + " " + "Successfully Registered, Please LogIn To Proceed";
 *                  WarehouseBusinessLayer wbl = new WarehouseBusinessLayer();
 *                  if (account.signUp.Role == "Manager")
 *                      {
 *
 *                          int Managerid = wbl.getRecentlyId();
 *                          wbl.createWarehouse(Managerid);
 *
 *                      }
 *                  Session["UserID"] = wbl.getRecentlyId();
 *                      Session["Username"] = account.signUp.UserName.ToString();
 *                      success = true;
 *
 **/
            }



            if (success)
            {
                return(RedirectToAction("StepTwoManager"));
            }
            else
            {
                return(View());
            }
        }
Ejemplo n.º 2
0
        public RedirectToRouteResult CreateWorker(string fullname, string email, string number, string username, string password, string[] shelfs)
        {
            WarehouseDBEntities wde = new WarehouseDBEntities();
            UserAccount         acc = new UserAccount();

            acc.Email      = email;
            acc.Name       = fullname;
            acc.UserName   = username;
            acc.Password   = password;
            acc.Contact    = number;
            acc.Role       = "Worker";
            acc.Registered = DateTime.Now.ToShortDateString();
            wde.Workers.Add(new Worker
            {
                warehouseId    = Convert.ToInt32(Session["UserId"]),
                assignedShelfs = JsonConvert.SerializeObject(shelfs)
            });
            if (wde.UserAccounts.Where(a => a.UserName == acc.UserName).ToList().Count < 1)
            {
                try
                {
                    wde.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;
                }

                // acc.workerId = Convert.ToInt32(Session["UserId"]);
                acc.workerId = wde.Workers.Max(a => a.Id);
                ConsignmentBusinessLayer cbl = new ConsignmentBusinessLayer();
                cbl.addAccount(acc);

                return(RedirectToAction("ViewWorkers"));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        public JsonResult GetWarehouses(string id)
        {
            try
            {
                ConsignmentBusinessLayer cbl       = new ConsignmentBusinessLayer();
                List <Warehouse>         warehouse = cbl.getNameAddress(id);


                return(new JsonResult {
                    Data = warehouse, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        public ActionResult DeleteItem(List <Item_Consignment> itemcon)
        {
            Item_Consignment it = itemcon.ElementAt(0);
            Item_Consignment ic = db.Item_Consignment.FirstOrDefault(i => i.consignmentId == it.consignmentId && i.itemId == it.itemId);

            db.Item_Consignment.Remove(ic);
            db.SaveChanges();


            int count = db.Item_Consignment.Where(u => u.consignmentId == ic.consignmentId).Count();
            ConsignmentBusinessLayer cbl = new ConsignmentBusinessLayer();

            cbl.updateItemsCount(count, ic.consignmentId);

            //Write code to update item count
            return(RedirectToAction("Index", "Consignments"));
        }
Ejemplo n.º 5
0
        public JsonResult GetItems(int warehouseId)
        {
            List <Item>              items = new List <Item>();
            WarehouseDBEntities      wdb   = new WarehouseDBEntities();
            List <Item_Warehouse>    iw    = wdb.Item_Warehouse.Where(i => i.warehouseId == warehouseId).ToList();
            ConsignmentBusinessLayer cbl   = new ConsignmentBusinessLayer();

            foreach (Item_Warehouse i in iw)
            {
                //Item it = wdb.Items.First(k=>k.id==i.itemId);
                items.Add(cbl.getItem(i.itemId, (int)i.quantity));
            }

            wdb.Dispose();


            return(new JsonResult {
                Data = items, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }