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 UserHomepage() { using (Administration_DatabaseEntities1 db = new Administration_DatabaseEntities1()) { var username = User.Identity.GetUserName(); var currentUser = re.GetCurrentUser(username); var model = new UserViewModel(); model.User = re.GetCurrentUser(username); model.Today = re.GetTodayReminders(currentUser.EmployeeId); model.ThisWeek = re.GetWeekReminders(currentUser.EmployeeId); model.BillsDue = re.GetBillsDue(currentUser.EmployeeId); ViewBag.Students = sr.GetAllStudents(); return(View(model)); } }
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)); }