Ejemplo n.º 1
0
        // GET: Absence
        public ActionResult Index(AbsenceViewModel avm)
        {
            try
            {
                ViewData["sessionData"] = new int?[] { HttpContext.Session.GetInt32("admin"), HttpContext.Session.GetInt32("language") };
                avm.ActiveUser          = userBll.GetUserById((long)HttpContext.Session.GetInt32("userId"));
                avm.Dictionary          = new Dictionary(HttpContext.Session.GetInt32("language"));

                User user = new User();
                if (avm.UserCode != null && avm.UserCode != "")
                {
                    user = userBll.ShowAllUsers().FirstOrDefault(u => u.Login == avm.UserCode);
                }
                else
                {
                    user         = avm.ActiveUser;
                    avm.UserCode = avm.ActiveUser.Login;
                }
                avm.User     = user;
                avm.UserId   = user.UserId;
                avm.Absences = new AbsenceFE().GetAbsensesFE(absenceBll.ShowAllAbsences().Where(a => a.UserId == avm.UserId && a.EndDate >= DateTime.Today));

                if (avm.ConflictReservatie)
                {
                    ViewData["message"] = avm.Dictionary.Label21;
                }

                return(View(avm));
            }
            catch (Exception)
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Create(BuildingViewModel bvm)
        {
            try
            {
                activeUser = userBll.GetUserById((long)HttpContext.Session.GetInt32("userId"));
                if (activeUser.Administrator > 0)
                {
                    Building building = new Building
                    {
                        BuildingCode = bvm.BuildingCode,
                        City         = bvm.City,
                        Name         = bvm.Name,
                        Street       = bvm.Street,
                        Number       = bvm.Number,
                        ZipCode      = bvm.ZipCode
                    };

                    buildingBll.CreateBuilding(building);
                    long buildingId = buildingBll.ShowAllBuildings().FirstOrDefault(b => b.BuildingCode == building.BuildingCode).BuildingId;

                    for (int i = 0; i < bvm.NumberOfFloors; i++)
                    {
                        Floor floor = new Floor();
                        floor.BuildingId = buildingId;
                        floor.Name       = building.Name + " " + i;
                        floor.FloorCode  = building.BuildingCode + i.ToString("00");
                        floor.Number     = i;
                        floorBll.CreateFloor(floor);
                    }

                    ViewData["sessionData"] = new int?[] { HttpContext.Session.GetInt32("admin"), HttpContext.Session.GetInt32("language") };
                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    ViewData["sessionData"] = new int?[] { HttpContext.Session.GetInt32("admin"), HttpContext.Session.GetInt32("language") };
                    return(View());
                }
            }
            catch
            {
                ViewData["sessionData"] = new int?[] { HttpContext.Session.GetInt32("admin"), HttpContext.Session.GetInt32("language") };
                return(View());
            }
        }
Ejemplo n.º 3
0
 //Reset password
 public ActionResult ResetPassword(long id)
 {
     try
     {
         User user = userBll.GetUserById(id);
         user.Password = "******";
         userBll.UpdateUser(id, user);
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception)
     {
         return(RedirectToAction(nameof(Index)));
     }
 }
Ejemplo n.º 4
0
        public ActionResult Create(FlexDesk desk)
        {
            try
            {
                activeUser = userBll.GetUserById((long)HttpContext.Session.GetInt32("userId"));
                if (activeUser.Administrator > 0)
                {
                    flexDeskBll.CreateFlexDesk(desk);
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                ViewData["sessionData"] = new int?[] { HttpContext.Session.GetInt32("admin"), HttpContext.Session.GetInt32("language") };
                return(RedirectToAction(nameof(Index)));
            }
        }
        public ActionResult Create(DepartmentViewModel dvm)
        {
            try
            {
                activeUser = userBll.GetUserById((long)HttpContext.Session.GetInt32("userId"));
                ViewData["sessionData"] = new int?[] { HttpContext.Session.GetInt32("admin"), HttpContext.Session.GetInt32("language") };

                if (activeUser.Administrator > 0)
                {
                    Department department = new Department
                    {
                        Name           = dvm.Name,
                        DepartmentCode = dvm.DepartmentCode,
                        FloorId        = dvm.FloorId,
                        Svg            = dvm.Svg
                    };

                    departmentBll.CreateDepartment(department);
                    long departmentId = departmentBll.ShowAllDepartments().FirstOrDefault(d => d.DepartmentCode == department.DepartmentCode).DepartmentId;

                    for (int i = 1; i < dvm.NumberOfDesks + 1; i++)
                    {
                        FlexDesk desk = new FlexDesk();
                        desk.DepartmentId = departmentId;
                        desk.FlexDeskCode = department.DepartmentCode + i.ToString("000");;
                        desk.Name         = department.Name + " " + i.ToString("000");
                        flexDeskBll.CreateFlexDesk(desk);
                    }
                }

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(RedirectToAction(nameof(Index)));
            }
        }
Ejemplo n.º 6
0
 public User Get(long id)
 {
     return(userBll.GetUserById(id));
 }
Ejemplo n.º 7
0
 public User Get(long id)
 {
     //return userProvider.GetById(id);
     return(userBll.GetUserById(id));
 }
Ejemplo n.º 8
0
 public ActionResult GetUserById(int id)
 {
     return(Ok(Json(_userBll.GetUserById(id))));
 }
        public IActionResult Index(ReservationViewModel rvm)
        {
            try
            {
                ViewData["sessionData"] = new int?[] { HttpContext.Session.GetInt32("admin"), HttpContext.Session.GetInt32("language") };
                this.rvm       = rvm;
                activeUser     = userBll.GetUserById((long)HttpContext.Session.GetInt32("userId"));
                rvm.ActiveUser = activeUser;
                rvm.Dictionary = new Dictionary(HttpContext.Session.GetInt32("language"));
                if (rvm.UserCode != null)
                {
                    rvm.User = userBll.ShowAllUsers().FirstOrDefault(u => u.Login == rvm.UserCode);
                    if (rvm.User == null)
                    {
                        ViewData["message2"] = "User not found";
                        rvm.User             = activeUser;
                        rvm.UserCode         = activeUser.Login;
                    }
                }
                else
                {
                    rvm.User     = activeUser;
                    rvm.UserCode = activeUser.Login;
                }

                rvm.UserId = rvm.User.UserId;
                rvm.Start  = DateTime.Today;
                rvm.End    = DateTime.Today;
                IEnumerable <Reservation> reservations = reservationBll.ShowAllReservations().Where(r => r.UserId == rvm.User.UserId && r.EndDate >= DateTime.Today);
                rvm.Reservations = new ReservationFE().GetReservations(flexDeskBll, reservations);

                ViewData["message"] = rvm.Message;
                return(View(rvm));
            }
            catch (Exception)
            {
                return(RedirectToAction("Index", "Home"));
            }
        }