public ActionResult CreateCourseSchedule(FormCollection col, int id) { string[] days = col["selectedDays"].Split(','); foreach (var day in days) { Course_Schedule newSchedule = new Course_Schedule(); newSchedule.CourseId = id; newSchedule.DayOfWeek = day; newSchedule.StartTime = TimeSpan.Parse(col["startTime"]); newSchedule.EndTime = TimeSpan.Parse(col["endTime"]); db.Course_Schedules.Add(newSchedule); db.SaveChanges(); } return(RedirectToAction("CourseDetails", "Course", new { id = id })); }
public ActionResult StudentDetails(FormCollection col) { if (col.AllKeys.Contains("selectedCourses")) { string[] courses = col["selectedCourses"].Split(','); foreach (var course in courses) { Student_Course newStudentCourse = new Student_Course() { StudentId = Convert.ToInt32(col["StudentId"]), RegistrationStatus = "Prospective", CourseId = Convert.ToInt32(course) }; db.Student_Courses.Add(newStudentCourse); db.SaveChanges(); } } var username = User.Identity.GetUserName(); var currentUser = ur.GetCurrentUser(username); if (col["notes"] != "") { Reminder newReminder = new Reminder() { StudentId = Convert.ToInt32(col["StudentId"]), AdvisorId = currentUser.EmployeeId, Date = Convert.ToDateTime(col["date"]), Notes = col["notes"], Completed = false }; db.Reminders.Add(newReminder); db.SaveChanges(); } return(RedirectToAction("StudentDetails", new { id = Convert.ToInt32(col["StudentId"]) })); }
public ActionResult CreateCourse(CourseViewModel model) { using (Administration_DatabaseEntities1 db = new Administration_DatabaseEntities1()) { Course newCourse = model.Course; Course_Detail cd = model.CourseDetail; cd.TeacherId = model.CourseDetail.TeacherId; newCourse.Course_Details = cd; db.Courses.Add(newCourse); db.Course_Details.Add(cd); db.SaveChanges(); } return(RedirectToAction("AllCourses")); }
public ActionResult EditEmployee(EmployeeViewModel model, int id) { using (Administration_DatabaseEntities1 db = new Administration_DatabaseEntities1()) { var employeeToEdit = (from e in db.People where e.PersonId == id select e).Single(); employeeToEdit.FirstName = model.Employee.FirstName; employeeToEdit.LastName = model.Employee.LastName; employeeToEdit.Phone = model.Employee.Phone; employeeToEdit.Email = model.Employee.Email; employeeToEdit.Employee.Salary = Convert.ToDecimal(model.EmployeeDetails.Salary); db.SaveChanges(); } return(RedirectToAction("EmployeeDetails", new { id = id })); }
public ActionResult EmployeeDetails(FormCollection col) { var bonus = re.GetBonuses(Convert.ToInt32(col["employeeId"])); var id = (Convert.ToInt32(col["employeeId"])); using (Administration_DatabaseEntities1 db = new Administration_DatabaseEntities1()) { Expens newPayment = new Expens(); newPayment.EmployeeId = id; newPayment.Amount = (Convert.ToDecimal(col["hours"]) * Convert.ToDecimal(col["salary"])) + bonus; newPayment.Paid = true; db.Expenses.Add(newPayment); db.SaveChanges(); } TempData["receipt"] = re.GetReceipt(); TempData["bonus"] = re.GetBonuses(id); return(RedirectToAction("EmployeeDetails", new { id = id })); //return RedirectToAction("PaymentReceipt", new { id = Convert.ToInt32(col["employeeId"])}); }
public async Task <ActionResult> Register(RegisterViewModel model, FormCollection col) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); using (Administration_DatabaseEntities1 myDb = new Administration_DatabaseEntities1()) { Person newUser = new Person() { FirstName = model.FName, LastName = model.LName, Phone = model.Phone, Email = model.Email, PersonType = "Faculty" }; myDb.People.Add(newUser); myDb.SaveChanges(); Employee newEmployee = new Employee() { EmployeeId = newUser.PersonId, EmployeeType = col["employeeType"], Username = model.Email, Password = model.Password, Salary = Convert.ToDecimal(col["salary"]), }; myDb.Employees.Add(newEmployee); myDb.SaveChanges(); //newUser.Employee = new Employee(); ////newUser.Employee.EmployeeId = newUser.PersonId; //newUser.Employee.Username = model.Email; //newUser.Employee.Password = model.Password; //newUser.Employee.EmployeeType = col["employeeType"]; //newUser.Employee.Salary = Convert.ToDecimal(col["salary"]); //myDb.Employees.Add(newUser.Employee); //myDb.SaveChanges(); } // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string 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 <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("UserHomepage", "User")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }