public ActionResult Edit([Bind(Include = "TicketStatusID,TicketStatusName,TicketStatusDescription")] TSTTicketStatus tSTTicketStatus)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tSTTicketStatus).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tSTTicketStatus));
 }
 public ActionResult Edit([Bind(Include = "ID,Name,Description,IsActive")] TSTDepartment tSTDepartment)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tSTDepartment).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tSTDepartment));
 }
 public ActionResult Edit([Bind(Include = "PriorityID,PriorityName,PriorityDescription")] TSTPriorite tSTPriorite)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tSTPriorite).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tSTPriorite));
 }
Example #4
0
 public ActionResult Edit([Bind(Include = "ID,Name,Description")] tstEmployeeStatu tstEmployeeStatu)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tstEmployeeStatu).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tstEmployeeStatu));
 }
 public ActionResult Edit([Bind(Include = "ID,TechID,TicketID,Notation,NotationDate")] tstTechNote tstTechNote)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tstTechNote).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TechID   = new SelectList(db.tstEmployees, "ID", "Name", tstTechNote.TechID);
     ViewBag.TicketID = new SelectList(db.tstTickets, "ID", "TroubleDescription", tstTechNote.TicketID);
     return(View(tstTechNote));
 }
Example #6
0
 public ActionResult Edit([Bind(Include = "EmployeeID,UserID,EmpStatusID,EmpImage,FName,LName,DeptID,JobTitle,DateOfBirth,StreetAddress,Address2,City,State,Zip,Email,CellPhone,DateOfHire,DateOfSeparation,EmpNotes")] TSTEmployee tSTEmployee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tSTEmployee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DeptID      = new SelectList(db.TSTDepartments, "DeptID", "DeptName", tSTEmployee.DeptID);
     ViewBag.EmpStatusID = new SelectList(db.TSTEmpStatuses, "EmpStatusID", "EmpStatusName", tSTEmployee.EmpStatusID);
     return(View(tSTEmployee));
 }
Example #7
0
 public ActionResult Edit([Bind(Include = "ID,Name,Lname,Hiredate,UserID,StatusID,Jobtitle,Adress,Adress2,City,State,Zip,Email,Phone,DepID,ImmageURL,Notes,Dateofbirth,separationDate")] tstEmployee tstEmployee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tstEmployee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepID    = new SelectList(db.tstDepartments, "ID", "Name", tstEmployee.DepID);
     ViewBag.StatusID = new SelectList(db.tstEmployeeStatus, "ID", "Name", tstEmployee.StatusID);
     return(View(tstEmployee));
 }
 public ActionResult Edit([Bind(Include = "EmpID,EmpFname,EmpLname,DeptID,EmpStatID,EmpAdd1,EmpAdd2,Area,Town_City,PostCode,PhoneNbr,UserID,DOB,DateOfHire,DateOfSeparation,Email,Image,Notes")] TSTEmployee tSTEmployee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tSTEmployee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DeptID    = new SelectList(db.TSTDepartments, "DeptID", "DeptName", tSTEmployee.DeptID);
     ViewBag.EmpStatID = new SelectList(db.TSTEmpStatus, "EmpStatID", "EmpStatName", tSTEmployee.EmpStatID);
     return(View(tSTEmployee));
 }
Example #9
0
 public ActionResult Edit([Bind(Include = "MailID,MailSubject,MailMessage,SentByID,DateSent,PriorityID,RecipientID,IsActive")] TSTMail tSTMail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tSTMail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SentByID    = new SelectList(db.TSTEmployees, "EmployeeID", "UserID", tSTMail.SentByID);
     ViewBag.RecipientID = new SelectList(db.TSTEmployees, "EmployeeID", "UserID", tSTMail.RecipientID);
     ViewBag.PriorityID  = new SelectList(db.TSTPriorities, "PriorityID", "PriorityName", tSTMail.PriorityID);
     return(View(tSTMail));
 }
Example #10
0
 public ActionResult Edit([Bind(Include = "TicketID,TicketSubject,TicketDescription,TicketImage,SubmittedByID,DateSubmitted,TicketStatusID,TechID,PriorityID,DateResolved")] TSTTicket tSTTicket)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tSTTicket).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.TechID         = new SelectList(db.TSTEmployees, "EmployeeID", "UserID", tSTTicket.TechID);
     ViewBag.SubmittedByID  = new SelectList(db.TSTEmployees, "EmployeeID", "UserID", tSTTicket.SubmittedByID);
     ViewBag.PriorityID     = new SelectList(db.TSTPriorities, "PriorityID", "PriorityName", tSTTicket.PriorityID);
     ViewBag.TicketStatusID = new SelectList(db.TSTTicketStatuses, "TicketStatusID", "TicketStatusName", tSTTicket.TicketStatusID);
     return(View(tSTTicket));
 }
 public ActionResult Edit([Bind(Include = "ID,SubmitedByID,TechID,CreatedDate,ResolutionDate,Description,StatusID,PriorityID,Subject")] TSTTicket tSTTicket)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tSTTicket).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SubmitedByID = new SelectList(db.TSTEmployees, "ID", "Fname", tSTTicket.SubmitedByID);
     ViewBag.TechID       = new SelectList(db.TSTEmployees.Where(e => e.TSTDepartment.ID == 7), "ID", "Fname", tSTTicket.TechID);
     ViewBag.PriorityID   = new SelectList(db.TSTTicketPriorities, "ID", "Name", tSTTicket.PriorityID);
     ViewBag.StatusID     = new SelectList(db.TSTTicketStatuses, "ID", "Name", tSTTicket.StatusID);
     return(View(tSTTicket));
 }
Example #12
0
        public ActionResult Edit([Bind(Include = "TicketID,TicketSubject,TicketDescription,SubmittedByID,TechID,TicketSubmitted,TicketResolved,TicketStatusID,Image,PriorityID")] TSTTicket tSTTicket)
        {
            if (ModelState.IsValid)
            {
                db.Entry(tSTTicket).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TechID         = new SelectList(db.TSTEmployees.Where(x => x.DepartmentID == 3), "EmpID", "EmpFname", tSTTicket.TechID);
            ViewBag.PriorityID     = new SelectList(db.TSTPriorites, "PriorityID", "PriorityName", tSTTicket.PriorityID);
            ViewBag.TicketStatusID = new SelectList(db.TSTTicketStatuses.Where(x => x.TicketStatusID != 1), "TicketStatusID", "TicketStatusName", tSTTicket.TicketStatusID);
            return(View(tSTTicket));
        }
Example #13
0
 public ActionResult Edit([Bind(Include = "ID,SubmitbyID,TechID,CreatedDate,ResoloutionDate,TroubleDescription,Screenshot,StatusID,PriorityID,Subject")] tstTicket tstTicket)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tstTicket).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.SubmitbyID = new SelectList(db.tstEmployees, "ID", "Name", tstTicket.SubmitbyID);
     ViewBag.TechID     = new SelectList(db.tstEmployees, "ID", "Name", tstTicket.TechID);
     ViewBag.PriorityID = new SelectList(db.tstTicketPriorties, "ID", "Name", tstTicket.PriorityID);
     ViewBag.StatusID   = new SelectList(db.tstTicketStatus, "ID", "Name", tstTicket.StatusID);
     return(View(tstTicket));
 }
        public ActionResult Edit([Bind(Include = "ID,Fname,Lname,DOB,Address1,Address2,City,State,Zip,Email,Phone,HireDate,SeparationDate,JobTitle,IsActive,Image,Note,UserID,DeptID,StatusID")]
                                 TSTEmployee tSTEmployee, HttpPostedFileBase empImage)
        {
            if (ModelState.IsValid)
            {
                #region FileUpload
                //empImage
                //default the value of the imageName to
                //string imageName = tSTEmployee.Image;

                if (empImage != null)
                {
                    //get the filename
                    string imageName = empImage.FileName;

                    //use the filename to get the extension
                    string ext = imageName.Substring(imageName.LastIndexOf('.')).ToLower();

                    // conversation about malicious code
                    // white list
                    string[] goodExts = new string[] { ".png", ".jpg", ".jpeg", ".gif" };

                    if (goodExts.Contains(ext))
                    {
                        // rename the file using a guid and add the ext
                        imageName = Guid.NewGuid() + ext;

                        // save to the webserver
                        empImage.SaveAs(Server.MapPath("~/Images/EmployeeImages/" + imageName));
                        tSTEmployee.Image = imageName;
                    }
                    else
                    {
                        // if nothing else change image back to no photo
                        imageName = "No-Image.svg.png";
                    }
                }
                #endregion

                db.Entry(tSTEmployee).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.DeptID   = new SelectList(db.TSTDepartments, "ID", "Name", tSTEmployee.DeptID);
            ViewBag.StatusID = new SelectList(db.TSTEmployeeStatuses, "ID", "Name", tSTEmployee.StatusID);
            return(View(tSTEmployee));
        }
Example #15
0
        public ActionResult Edit([Bind(Include = "EmpID,EmpFname,EmpLname,DepartmentID,EmpStatusID,EmpAddress1,EmpAddress2,EmpCity,EmpState,EmpPhoto,EmpUserID,EmpDateOfBirth,EmpDateOfHire,EmpEndDate,EmpPhone,EmpEmail,EmpNotes")] TSTEmployee tSTEmployee, string img, string grabPic)
        {
            ModelState.Clear();
            if (ModelState.IsValid)
            {
                // string imageName = grabPic;
                ////get images for delete
                ////check if file is empty
                //if (img != null)
                //{
                //    imageName = img.Substring(img.LastIndexOf('/') + 1);

                //}
                //tSTEmployee.EmpPhoto = imageName;


                //create the user manager

                //send back to identitiy default pass

                //add the user to selected roles
                var userManager = System.Web.HttpContext.Current.GetOwinContext()
                                  .GetUserManager <ApplicationUserManager>();
                //grab the user's user id, then the role, then remove them from the role, based on department
                var newUser  = userManager.FindByEmail(tSTEmployee.EmpEmail);
                var userRole = userManager.GetRoles(newUser.Id.ToString());

                //manages role and status assignment
                switch (tSTEmployee.DepartmentID)
                {
                case 1:    //admin
                    tSTEmployee.EmpStatusID = 1;
                    userManager.RemoveFromRole(newUser.Id.ToString(), userRole[0]);
                    userManager.AddToRole(newUser.Id.ToString(), "Admin");
                    break;

                case 3:    //teacher
                    tSTEmployee.EmpStatusID = 1;
                    userManager.RemoveFromRole(newUser.Id.ToString(), userRole[0]);
                    userManager.AddToRole(newUser.Id.ToString(), "Tech");
                    break;

                case 4:    //HR
                    tSTEmployee.EmpStatusID = 1;
                    userManager.RemoveFromRole(newUser.Id.ToString(), userRole[0]);
                    userManager.AddToRole(newUser.Id.ToString(), "Teacher");
                    break;

                case 5:
                    tSTEmployee.EmpStatusID = 1;
                    userManager.RemoveFromRole(newUser.Id.ToString(), userRole[0]);
                    userManager.AddToRole(newUser.Id.ToString(), "HR");
                    break;

                default:    //student
                    tSTEmployee.EmpStatusID = 2;
                    userManager.RemoveFromRole(newUser.Id.ToString(), userRole[0]);
                    userManager.AddToRole(newUser.Id.ToString(), "Student");
                    break;
                }


                db.Entry(tSTEmployee).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            if (tSTEmployee.DepartmentID == 6)
            {
                ViewBag.EmpStatusID = new SelectList(db.TSTEmployeeStatuses.Where(s => s.EmpStatusID.Equals(2) || s.EmpStatusID.Equals(4) || s.EmpStatusID.Equals(6)), "EmpStatusID", "EmpStatusName", tSTEmployee.EmpStatusID);
            }
            else
            {
                ViewBag.EmpStatusID  = new SelectList(db.TSTEmployeeStatuses.Where(s => s.EmpStatusID.Equals(1) || s.EmpStatusID.Equals(3) || s.EmpStatusID.Equals(5)), "EmpStatusID", "EmpStatusName", tSTEmployee.EmpStatusID);
                ViewBag.DepartmentID = new SelectList(db.TSTDepartments.Where(d => d.DepartmentID != tSTEmployee.DepartmentID).Where(d => d.DepartmentID != 6), "DepartmentID", "DepartmentName", tSTEmployee.DepartmentID);
            }
            ViewBag.State = new SelectList(GetProvincesList());
            return(View(tSTEmployee));
        }