示例#1
0
        public ActionResult Create([Bind(Include = "OwnerAssetID,AssetName,OwnerID,AssetPhoto,LevelID,SpecialNotes,IsActive,DateAdded")] OwnerAsset ownerAsset, HttpPostedFileBase assetPhoto)
        {
            if (ModelState.IsValid)
            {
                string imgName = "NoImage.png";
                if (assetPhoto != null)
                {
                    imgName = assetPhoto.FileName;
                    string   ext      = imgName.Substring(imgName.LastIndexOf('.'));
                    string[] goodExts = { ".jpeg", ".jpg", ".png", ".gif" };
                    if (goodExts.Contains(ext.ToLower()) && (assetPhoto.ContentLength <= 4194304))
                    {
                        imgName = Guid.NewGuid() + ext;
                        assetPhoto.SaveAs(Server.MapPath("~/Content/img/" + imgName));
                    }
                    else
                    {
                        imgName = "NoImage.png";
                    }
                }
                ownerAsset.AssetPhoto = imgName;
                ownerAsset.DateAdded  = DateTime.Now;
                ownerAsset.OwnerID    = User.Identity.GetUserId();
                db.OwnerAssets.Add(ownerAsset);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.LevelID = new SelectList(db.Levels, "LevelID", "LevelName", ownerAsset.LevelID);
            ViewBag.OwnerID = new SelectList(db.UserDetails, "UserID", "FirstName", ownerAsset.OwnerID);
            return(View(ownerAsset));
        }
示例#2
0
        public ActionResult DeleteConfirmed(int id)
        {
            Reservation reservation = db.Reservations.Find(id);

            db.Reservations.Remove(reservation);
            db.SaveChanges();
            return(RedirectToAction("ReservationSearch"));
        }
示例#3
0
        public ActionResult Create([Bind(Include = "LevelID,LevelName,Description")] Level level)
        {
            if (ModelState.IsValid)
            {
                db.Levels.Add(level);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(level));
        }
示例#4
0
        public ActionResult Create([Bind(Include = "PositionId,Title,JobDescription")] Position position)
        {
            if (ModelState.IsValid)
            {
                db.Positions.Add(position);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(position));
        }
示例#5
0
        public ActionResult Create([Bind(Include = "UserID,FirstName,LastName")] UserDetail userDetail)
        {
            if (ModelState.IsValid)
            {
                db.UserDetails.Add(userDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(userDetail));
        }
示例#6
0
        public ActionResult Create([Bind(Include = "CourseCompletionId,Userid,CourseID,DateCompleted")] CourseCompletion courseCompletion)
        {
            if (ModelState.IsValid)
            {
                db.CourseCompletions.Add(courseCompletion);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(courseCompletion));
        }
示例#7
0
        public ActionResult Create([Bind(Include = "ApplicationStatusId,StatusName,StatusDescription")] ApplicationStatu applicationStatu)
        {
            if (ModelState.IsValid)
            {
                db.ApplicationStatus.Add(applicationStatu);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(applicationStatu));
        }
示例#8
0
        public ActionResult Create([Bind(Include = "LocationID,LocationName,InstructorName,Address,City,State,ZipCode")] Location location)
        {
            if (ModelState.IsValid)
            {
                db.Locations.Add(location);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(location));
        }
示例#9
0
        public ActionResult Create([Bind(Include = "UserID,FirstName,LastName,CourseCompletetionID")] UserDetail userDetail)
        {
            if (ModelState.IsValid)
            {
                db.UserDetails.Add(userDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CourseCompletetionID = new SelectList(db.CourseCompletions, "CourseCompletionId", "Userid");
            return(View(userDetail));
        }
示例#10
0
        public ActionResult Create([Bind(Include = "LocationId,StoreNumber,City,State,ManagerId")] Location location)
        {
            if (ModelState.IsValid)
            {
                db.Locations.Add(location);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ManagerId = new SelectList(db.UserDetails, "UserId", "FirstName", location.ManagerId);
            return(View(location));
        }
示例#11
0
        public ActionResult Create([Bind(Include = "ClassID,ClassName,Description,ClassDate,LevelRequired,ClassLimit")] ClassInfo classInfo)
        {
            if (ModelState.IsValid)
            {
                db.ClassInfoes.Add(classInfo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.LevelRequired = new SelectList(db.Levels, "LevelID", "LevelName", classInfo.LevelRequired);
            return(View(classInfo));
        }
示例#12
0
        public ActionResult Create([Bind(Include = "LessonViewID,UserID,LessonID,DateViewed")] LessonView lessonView)
        {
            if (ModelState.IsValid)
            {
                db.LessonViews.Add(lessonView);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.LessonID = new SelectList(db.Lessons, "LessonID", "LessonName", lessonView.LessonID);
            ViewBag.UserID   = new SelectList(db.UserDetails, "UserID", "FirstName", lessonView.UserID);
            return(View(lessonView));
        }
示例#13
0
        public ActionResult Create([Bind(Include = "ApplicationId,OpenPositionId,UserId,ApplicationDate,ManagerNote,ApplicationStatus,ResumeFilename")] Application application)
        {
            if (ModelState.IsValid)
            {
                db.Applications.Add(application);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ApplicationStatus = new SelectList(db.ApplicationStatus, "ApplicationStatusId", "StatusName", application.ApplicationStatus);
            ViewBag.OpenPositionId    = new SelectList(db.OpenPositions, "OpenPositionId", "OpenPositionId", application.OpenPositionId);
            ViewBag.UserId            = new SelectList(db.UserDetails, "UserId", "FirstName", application.UserId);
            return(View(application));
        }
示例#14
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    UserDetail newUser = new UserDetail();
                    newUser.UserID    = user.Id;
                    newUser.FirstName = model.FirstName;
                    newUser.LastName  = model.LastName;
                    FSDPEntities db = new FSDPEntities();
                    db.UserDetails.Add(newUser);
                    db.SaveChanges();

                    //var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    //var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    //await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");
                    //ViewBag.Link = callbackUrl;
                    UserManager.AddToRole(user.Id, "Owner");
                    OwnerAsset id = new OwnerAsset();
                    id.OwnerID = User.Identity.GetUserId();
                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
示例#15
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email,
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    #region custom userdetails
                    UserDetail newUser = new UserDetail
                    {
                        UserID    = user.Id,
                        FirstName = model.FirstName,
                        LastName  = model.LastName
                    };

                    FSDPEntities db = new FSDPEntities();
                    db.UserDetails.Add(newUser);
                    db.SaveChanges();

                    #endregion

                    UserManager.AddToRole(user.Id, "Employee");

                    return(RedirectToAction("Login"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
示例#16
0
        public ActionResult Apply(int id) //what is filling out application when employee clicks to apply
        {
            Application app = new Application();

            app.UserId            = User.Identity.GetUserId();
            app.OpenPositionId    = id;
            app.ApplicationDate   = DateTime.Now;
            app.ManagerNote       = " ";                                                              //leave empty
            app.ApplicationStatus = 5;                                                                //choose 1 if 5 is not working(pending)
            string     appUser    = User.Identity.GetUserId();                                        //create another variable for top variable to flow into, method that comes with Identity samples that grabs whoever is on site
            UserDetail userDetail = db.UserDetails.Where(x => x.UserId == appUser).SingleOrDefault(); //SingleOrDefault returns only the element of the sequence

            app.ResumeFilename = userDetail.ResumeFilename;                                           //transferring above data to the application
            db.Applications.Add(app);
            db.SaveChanges();
            //go to openposition in tt files to complete this
            return(RedirectToAction("Index", "Applications"));
        }
示例#17
0
        public ActionResult Create([Bind(Include = "ReservationID,OwnerAssetID,LocationID,ClassID")] Reservation reservation)
        {
            int nbrRes = db.Reservations.Where(c => c.ClassID == reservation.ClassID).Count();
            int nbrMax = db.ClassInfoes.Where(m => m.ClassID == reservation.ClassID).FirstOrDefault().ClassLimit;
            int lvl    = db.ClassInfoes.Where(l => l.ClassID == reservation.ClassID).FirstOrDefault().LevelRequired;
            int memlvl = db.OwnerAssets.Where(q => q.OwnerAssetID == reservation.OwnerAssetID).FirstOrDefault().LevelID;

            TempData["reservation"] = nbrRes;
            if (ModelState.IsValid)
            {
                if (User.IsInRole("Admin"))
                {
                    db.Reservations.Add(reservation);
                    db.SaveChanges();
                }
                //Add functionality for class restrictions
                if (db.Reservations.Where(o => o.OwnerAssetID == reservation.OwnerAssetID).Count() > 0)
                {
                    return(RedirectToAction("Index"));
                }
                if (lvl > memlvl)
                {
                    return(RedirectToAction("Index"));
                }
                if (nbrRes < nbrMax)
                {
                    db.Reservations.Add(reservation);
                    db.SaveChanges();

                    return(RedirectToAction("Index"));
                }

                else
                {
                    return(RedirectToAction("Index"));
                }
            }

            ViewBag.ClassID      = new SelectList(db.ClassInfoes.Where(c => c.LevelRequired == reservation.OwnerAsset.LevelID), "ClassID", "ClassName", reservation.ClassID);
            ViewBag.LocationID   = new SelectList(db.Locations, "LocationID", "LocationName", reservation.LocationID);
            ViewBag.OwnerAssetID = new SelectList(db.OwnerAssets, "OwnerAssetID", "AssetName", reservation.OwnerAssetID);
            return(View(reservation));
        }
示例#18
0
        public ActionResult Create([Bind(Include = "CourseID,CourseName,CourseDescription,isActive,Photo")] HttpPostedFileBase IMG, Cours cours)
        {
            if (ModelState.IsValid)
            {
                string pic = "noFile.pdf";

                if (IMG != null)
                {
                    pic = IMG.FileName;

                    string ext = pic.Substring(pic.LastIndexOf('.'));

                    string[] goodExts = { ".png", ".jpg", ".jpeg" };

                    if (goodExts.Contains(ext.ToLower()))
                    {
                        //save file to webserver
                        IMG.SaveAs(Server.MapPath("~/Content/images/fulls/" + pic));
                    }
                }

                else
                {
                    //otherwise default back to the default image.
                    pic = "noimg.png";
                }


                cours.Photo = pic;

                db.Courses.Add(cours);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cours));
        }
示例#19
0
        public ActionResult UploadResume(int id)
        {
            UserDetail ud = new UserDetail();

            ud.ResumeFilename = ud.ResumeFilename;
            string userId = User.Identity.GetUserId();

            UserDetail details = db.UserDetails.Where(x => x.UserId == userId).SingleOrDefault();

            ud.ResumeFilename = details.ResumeFilename;
            db.UserDetails.Add(ud);
            db.SaveChanges();

            return(RedirectToAction("Index", "Home"));
        }
示例#20
0
        // GET: Lessons/Details/5
        public ActionResult Details(int?id, bool?completed)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Lesson lesson = db.Lessons.Find(id);

            if (lesson == null)
            {
                return(HttpNotFound());
            }
            if (lesson.VideoURL != null)
            {
                var    v   = lesson.VideoURL.IndexOf("v=");
                var    amp = lesson.VideoURL.IndexOf("&", v);
                string vid;
                //if the video id is the last value in the url
                if (amp == -1)
                {
                    vid = lesson.VideoURL.Substring(v + 2);
                    // if there are other parameters after the video id in the url
                }
                else
                {
                    vid = lesson.VideoURL.Substring(v + 2, amp - (v + 2));
                }
                ViewBag.VideoID = vid;
            }

            if (User.IsInRole("Employee") && completed == true)
            {
                LessonView viewed = new LessonView
                {
                    UserID     = User.Identity.GetUserId(),
                    DateViewed = DateTime.Now,
                    LessonID   = (int)id
                };
                db.LessonViews.Add(viewed);
                db.SaveChanges();
                //if(db.LessonViews.Where(l => l.UserID == viewed.UserID && l.Lesson.CourseID == lesson.CourseID).Count() == db.Lessons.Where(l => l.CourseID == lesson.CourseID).Count())
                //{
                //    CourseCompletion comp = new CourseCompletion
                //    {
                //        Userid = User.Identity.GetUserId(),
                //        DateCompleted = DateTime.Now,
                //        CourseID = lesson.CourseID
                //    };

                //    db.CourseCompletions.Add(comp);
                //    db.SaveChanges();
                //}
                if (db.LessonViews.Where(l => l.UserID == viewed.UserID && l.Lesson.CourseID == lesson.CourseID).Count() == db.Lessons.Where(l => l.CourseID == lesson.CourseID).Count())
                {
                    CourseCompletion comp = new CourseCompletion
                    {
                        Userid        = User.Identity.GetUserId(),
                        DateCompleted = DateTime.Now,
                        CourseID      = lesson.CourseID
                    };
                    db.CourseCompletions.Add(comp);
                    db.SaveChanges();

                    // 1) Build the email message body (content for the email)
                    string message = $"A course has been completed, check course completion page for updated information.<br>" +
                                     $"";

                    // 2) Create the MailMessage object, and customize
                    MailMessage msg = new MailMessage(
                        //FROM - your domain email ([email protected])
                        "*****@*****.**",
                        //TO - where the email lands (should be sent to your personal email)
                        "*****@*****.**",
                        //subject
                        "Completed Course",
                        //Body
                        message
                        );

                    //allow HTML formatting
                    msg.IsBodyHtml = true;
                    msg.Priority   = MailPriority.Normal; //cna change priority
                                                          //CC  or BCC other recipients


                    // 3) Create the SmtpClient that will send the email.
                    //the client will need info from the host to route the email
                    SmtpClient client = new SmtpClient("mail.TheWongpage.com");
                    client.Credentials = new NetworkCredential("*****@*****.**", "Smokes#1");


                    // 4) Attempt sending email.
                    try
                    {
                        client.Send(msg);
                    }
                    catch (Exception ex)
                    {
                        ViewBag.ErrorMessage = $"Sorry, something went wrong. Pelase try again later or review the stacktrace <br>{ex.StackTrace}";
                        return(View());
                    }

                    //if the email gets send, we will send the user to a confirmation view.
                    return(RedirectToAction("TileView", "Cours"));
                }
                ;

                return(RedirectToAction("Index", new { id = lesson.CourseID }));
            }

            return(View(lesson));
        }