public bool clockUserIn()
        {
            TIME_SHEET_ENTRY timeSheetEntry = new TIME_SHEET_ENTRY();

            int id = (int)TempData["id"];

            TempData.Keep("id");

            var activeTimeSheet = db.TIME_SHEET.Where(timeSheet => timeSheet.employee == id).FirstOrDefault();
            var user            = db.USERs.Where(employee => employee.userID == id).FirstOrDefault();
            var timeType        = "paid";

            timeSheetEntry.employee = id;

            //check if the user is clocking in as food service, if so set their time type to food service.
            var isFoodService = TempData["isFoodService"];

            if (isFoodService.Equals("True"))
            {
                timeType = "food";
            }

            timeSheetEntry.clock_in_time = System.DateTime.Now;
            timeSheetEntry.date          = System.DateTime.Now;
            timeSheetEntry.created_on    = System.DateTime.Now;
            timeSheetEntry.is_clocked_in = true;
            timeSheetEntry.time_type     = timeType;
            db.TIME_SHEET_ENTRY.Add(timeSheetEntry);
            db.SaveChanges();
            return(true);
        }
Exemple #2
0
        public ActionResult Edit(EditView myModel)
        {
            USER uSER = myModel.User;

            //LOGIN LUser = myModel.LUser;
            //PAID_STAFF PUser = myModel.PUser;

            if (Request.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    if (myModel.User.user_type != "Volunteer" && myModel.PUser == null)
                    {
                        ViewBag.location = new SelectList(db.LOCATIONs, "locationID", "name", uSER.location);
                        ViewBag.userID   = new SelectList(db.PAID_STAFF, "emplID", "pay_schedule", uSER.userID);
                        ViewBag.userID   = new SelectList(db.UNIT_DIRECTOR, "emplID", "emplID", uSER.userID);
                        ViewBag.manager  = new SelectList(db.USERs, "userID", "fname", uSER.manager);
                        ViewBag.userID   = new SelectList(db.VOLUNTEERs, "volID", "volID", uSER.userID);

                        PAID_STAFF newPaid = new PAID_STAFF();
                        newPaid.emplID = myModel.User.userID;
                        db.PAID_STAFF.Add(newPaid);
                        myModel.PUser = newPaid;
                        db.SaveChanges();
                        return(View(myModel));
                    }

                    db.Entry(myModel.User).State  = EntityState.Modified;
                    db.Entry(myModel.LUser).State = EntityState.Modified;
                    if (myModel.PUser != null)
                    {
                        db.Entry(myModel.PUser).State = EntityState.Modified;
                    }
                    if (myModel.User.user_type == "Volunteer" && myModel.PUser != null)
                    {
                        PAID_STAFF old = db.PAID_STAFF.Find(myModel.PUser.emplID);
                        db.PAID_STAFF.Remove(old);
                    }
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                ViewBag.location = new SelectList(db.LOCATIONs, "locationID", "name", uSER.location);
                ViewBag.userID   = new SelectList(db.PAID_STAFF, "emplID", "pay_schedule", uSER.userID);
                ViewBag.userID   = new SelectList(db.UNIT_DIRECTOR, "emplID", "emplID", uSER.userID);
                ViewBag.manager  = new SelectList(db.USERs, "userID", "fname", uSER.manager);
                ViewBag.userID   = new SelectList(db.VOLUNTEERs, "volID", "volID", uSER.userID);

                return(View(myModel));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        public ActionResult AdminChangePassword(ChangePasswordViewModel ChangePassModel)
        {
            int          id             = (int)TempData["User"];
            var          user           = db.LOGINs.Where(x => x.userID == id).FirstOrDefault();
            PasswordHash pass           = new PasswordHash();
            string       userSaltString = user.password_salt;

            byte[] ss = Convert.FromBase64String(userSaltString);

            user.password = pass.GetHash(ChangePassModel.NewPassword, ss);
            db.SaveChanges();

            return(RedirectToAction("Index", "Home"));
            //return RedirectToAction("UserPortal", "Users");
        }
 public ActionResult Edit([Bind(Include = "emplID,pto_accrual_rate,max_pto_accrual,total_pto_accrued,pay_rate,pay_schedule")] PAID_STAFF pAID_STAFF)
 {
     if (Request.IsAuthenticated)
     {
         if (ModelState.IsValid)
         {
             db.Entry(pAID_STAFF).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         ViewBag.emplID = new SelectList(db.USERs, "userID", "fname", pAID_STAFF.emplID);
         return(View(pAID_STAFF));
     }
     else
     {
         return(RedirectToAction("Index", "Home"));
     }
 }
        public ActionResult Create([Bind(Include = "locationID,name,address,street,city,state,country")] LOCATION lOCATION)
        {
            if (Request.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    db.LOCATIONs.Add(lOCATION);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(lOCATION));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Exemple #6
0
        public ActionResult Create([Bind(Include = "ppID,start_date,end_date,active,created_on,created_by")] PAY_PERIOD pAY_PERIOD)
        {
            if (Request.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    db.PAY_PERIOD.Add(pAY_PERIOD);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(pAY_PERIOD));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        public ActionResult Create([Bind(Include = "requestID,requested_by,total_time_requested,requested_on,approved,approved_on,approved_by,comments,pto_start,pto_end")] PTO_REQUEST pTO_REQUEST)
        {
            if (Request.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    db.PTO_REQUEST.Add(pTO_REQUEST);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.approved_by  = new SelectList(db.USERs, "userID", "fname", pTO_REQUEST.approved_by);
                ViewBag.requested_by = new SelectList(db.USERs, "userID", "fname", pTO_REQUEST.requested_by);
                return(View(pTO_REQUEST));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        public ActionResult Create([Bind(Include = "notifID,recipients,type,trigger,content,created_on,user_recipient,user_sender,active,expires")] NOTIFICATION nOTIFICATION)
        {
            if (Request.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    db.NOTIFICATIONs.Add(nOTIFICATION);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.user_recipient = new SelectList(db.USERs, "userID", "fname", nOTIFICATION.user_recipient);
                ViewBag.user_sender    = new SelectList(db.USERs, "userID", "fname", nOTIFICATION.user_sender);
                return(View(nOTIFICATION));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Exemple #9
0
        public ActionResult Create([Bind(Include = "timesheetID,employee,submitted_on,approved_on,approved_by,submitted,approved,comments,active,is_missing_punches,total_entries,total_hours_worked,total_overtime_worked,pay_period,total_pto_used,total_unpaid_time,created_on,total_pto_earned")] TIME_SHEET tIME_SHEET)
        {
            if (Request.IsAuthenticated)
            {
                if (ModelState.IsValid)
                {
                    db.TIME_SHEET.Add(tIME_SHEET);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                ViewBag.pay_period  = new SelectList(db.PAY_PERIOD, "ppID", "created_by", tIME_SHEET.pay_period);
                ViewBag.approved_by = new SelectList(db.USERs, "userID", "fname", tIME_SHEET.approved_by);
                ViewBag.employee    = new SelectList(db.USERs, "userID", "fname", tIME_SHEET.employee);
                return(View(tIME_SHEET));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
        public ActionResult Create(LOGIN newuser)
        {
            if (Request.IsAuthenticated)
            {
                using (trackerEntities db = new trackerEntities())
                {
                    PasswordHash pass = new PasswordHash();
                    pass.Salt = pass.GenerateSalt();

                    newuser.userID        = (int)TempData["u2"];
                    newuser.password      = (string)TempData["pass"];
                    newuser.password      = pass.GetHash(newuser.password, pass.Salt);
                    newuser.password_salt = Convert.ToBase64String(pass.Salt);
                    //int hash = newuser.password.GetHashCode();
                    //newuser.password_salt = hash; //password salt needs to be int ??

                    USER User = (USER)TempData["userModel"];
                    db.USERs.Add(User);
                    //db.SaveChanges();
                    if (User.user_type != "Volunteer")
                    {
                        PAID_STAFF pAID_STAFF = (PAID_STAFF)TempData["paidStaffModel"];
                        db.PAID_STAFF.Add(pAID_STAFF);
                        //db.SaveChanges();
                    }
                    db.LOGINs.Add(newuser);
                    db.SaveChanges();
                }
                ModelState.Clear();
                ViewBag.SuccessMessage = "Registration Success!";
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
            //return View("Create", new LOGIN());
        }