public void RemoveAlumnusSendList(int SendListId, string PersonCode) { Alumnus alumnusX = unitOfWork.Alumnuses.GetAlumnus(PersonCode); unitOfWork.SendLists.Get(SendListId).Alumnuses.Remove(alumnusX); unitOfWork.Save(); }
public ActionResult Accept(AlumniViewModel model) { // den Alumni anlegen, falls es ihn noch nicht gibt var student = Db.Students.SingleOrDefault(x => x.Id == model.Student.Id); var alumni = Db.Alumnae.SingleOrDefault(x => x.UserId.Equals(student.UserId) && x.Curriculum.Id == student.Curriculum.Id); // Standard: es gibt den alumni noch nicht if (alumni == null) { // anlegen, aber nicht speichern alumni = new Alumnus { Curriculum = student.Curriculum, Semester = student.LastSemester, UserId = student.UserId }; Db.Alumnae.Add(alumni); Db.SaveChanges(); return(RedirectToAction("ThankYou", new { id = alumni.Id })); } return(RedirectToAction("Curricula", "Subscription")); }
public void DeleteAlumnus2(string PersonCode) //form 4 { Alumnus alumnusX = unitOfWork.Alumnuses.GetAlumnus(PersonCode); unitOfWork.Alumnuses.Remover(alumnusX); unitOfWork.Save(); }
// Remove objekt public void RemoveAlumnusActivity(int ActivityId, string PersonCode) //form 4 { Alumnus alumnusX = unitOfWork.Alumnuses.GetAlumnus(PersonCode); unitOfWork.Activities.Get(ActivityId).Alumnuses.Remove(alumnusX); unitOfWork.Save(); }
//Delete public void DeleteAlumnus() //form 3 { Alumnus alumnusX = unitOfWork.Alumnuses.Get(PersonOnline.ID); unitOfWork.Alumnuses.Remover(alumnusX); unitOfWork.Save(); }
private void btn_registerAlumn_Click(object sender, EventArgs e) { if (password_txtbox.Text == Cpassword_txtbox.Text) { string username = UserN_txtbox.Text; string password = password_txtbox.Text; string email = Emai_txtbox.Text; string fName = Fname_txtbox.Text; string lName = Lname_txtbox.Text; int alumnNumber = int.Parse(Snr_txtbox.Text); string persCode = Pnr_txtbox.Text; Alumnus alumnus = new Alumnus(username, fName, lName, email, password); alumnus.Username = username; alumnus.Password = password; alumnus.PersonCode = persCode; alumnus.AlumnusId = alumnNumber; alumnus.Fname = fName; alumnus.Lname = lName; alumnus.Email = email; businessManager.CreateAlumnus(alumnus); DialogResult = DialogResult.OK; } }
private void Authentication() { Alumnus Alumnus = Alumnuses.Where(x => x.PersonCode == PersonCodeBox && x.Password == PasswordBox).FirstOrDefault(); Employee employee = Employees.Where(x => x.PersonCode == PersonCodeBox && x.Password == PasswordBox).FirstOrDefault(); if (Alumnus is Alumnus) { AlumnusViewModel.AlumnusOnline = Alumnus; AlumnusView Oppen = new AlumnusView(); Oppen.Show(); } else if (employee is Employee) { EmployeeViewModel.OnlineEmployee = employee; EmployeeView Open = new EmployeeView(); Open.Show(); } else { ErrorMessage = "Incorrect login"; } PersonCodeBox = string.Empty; PasswordBox = string.Empty; OnPropertyChanged("PersonCodeBox"); OnPropertyChanged("PasswordBox"); OnPropertyChanged("ErrorMessage"); }
public void DeleteAlumnus(int id) { Alumnus PickedAlumnus = UnitOfWork.alumnus.Get(id); UnitOfWork.alumnus.Remove(PickedAlumnus); UnitOfWork.Compelte(); }
private void btnSkapaAlumn_Click(object sender, EventArgs e) { if (Cbox.Checked) { Alumnus alumnus = new Alumnus( TxtBox_username.Text, TxtBoxFirstName.Text, TxtBoxLname.Text, TxtBoxEmail.Text, TxtBoxPassWord.Text); BusinessManager.CreateAlumnus(alumnus); TxtBox_username.Clear(); TxtBoxFirstName.Clear(); TxtBoxLname.Clear(); TxtBoxEmail.Clear(); TxtBoxPassWord.Clear(); ShowAlumni(); } else { MessageBox.Show("You have not confirmed the information to be saved"); } }
public async void LoadPeople() { var _people = await _personService.GetPeople(); People.AddRange(_people); Membri.AddRange(People.Where(t => !t.Position.Contains("Wannabe") && !t.Position.Contains("Alumnus"))); Wannabe.AddRange(People.Where(t => t.Position.Contains("Wannabe"))); Alumnus.AddRange(People.Where(t => t.Position.Contains("Alumnus"))); if (Membri.Count != 0) { MembriVisibility = "Visible"; } if (Alumnus.Count != 0) { AlumnusVisibility = "Visible"; } if (Wannabe.Count != 0) { WannabeVisibility = "Visible"; } ProgressBarVisibility = "Collapsed"; IsIndeterminate = "False"; }
public void AddAlumnusSenList(int SendListId, string PersonCode) //form 4 { Alumnus alumnusX = unitOfWork.Alumnuses.GetAlumnus(PersonCode); unitOfWork.SendLists.Get(SendListId).Alumnuses.Add(alumnusX); unitOfWork.Save(); }
public static void Populate(LibarysystemDBcontext libarysystemDBcontext) { Alumnus Olle = new Alumnus("OS", "Olle", "Sandahl", "*****@*****.**", "OS1"); libarysystemDBcontext.Alumni.Add(Olle); libarysystemDBcontext.Employees.Add(new Employee("OSU", "olle", "Sandal", "*****@*****.**", "OSU1")); libarysystemDBcontext.Programs.Add(new Program() { ProgramId = 1, Name = "Computer-Economics", }); libarysystemDBcontext.Programs.Add(new Program() { ProgramId = 2, Name = "System-Development" }); Aktivity aktivity = new Aktivity() { AktivityId = 1, Name = "Meeting", Description = "discuss common goals" }; libarysystemDBcontext.SaveChanges(); //adadada }
//Create public bool CreateAlumnus(Alumnus NewAlumnus) //form 2 { if (!unitOfWork.Alumnuses.GetAll().Any(x => x.PersonCode == NewAlumnus.PersonCode)) { unitOfWork.Alumnuses.Add(NewAlumnus); unitOfWork.Save(); return(true); } return(false); }
public void CreateAlumnus() { if (Alumnus.password == VerifyPassword) { Alumnus.CreateAlumn(); } else { System.Windows.MessageBox.Show("Test"); } }
public void ChangeAlumnus2(IAlumnus alumnus, string PersonCode) // form4 { Alumnus alumnusX = unitOfWork.Alumnuses.GetAlumnus(PersonCode); alumnusX.Fname = alumnus.Fname; alumnusX.Lname = alumnus.Lname; alumnusX.PersonCode = alumnus.PersonCode; alumnusX.Email = alumnus.Email; alumnusX.Password = alumnus.Password; alumnusX.Qualification = alumnus.Qualification; alumnusX.ExamDate = alumnus.ExamDate; unitOfWork.Save(); }
//Change public void ChangeAlumnus(IAlumnus TemporaryAlumn) //form 2 { Alumnus alumnusX = unitOfWork.Alumnuses.Get(PersonOnline.ID); alumnusX.Fname = TemporaryAlumn.Fname; alumnusX.Lname = TemporaryAlumn.Lname; alumnusX.PersonCode = TemporaryAlumn.PersonCode; alumnusX.Email = TemporaryAlumn.Email; alumnusX.Password = TemporaryAlumn.Password; alumnusX.Qualification = TemporaryAlumn.Qualification; alumnusX.ExamDate = TemporaryAlumn.ExamDate; unitOfWork.Save(); }
public void CreateAlumn() { Alumnus alumn = new Alumnus(); alumn.AlumnusId = int.Parse(alumnusId); alumn.Username = username; alumn.Fname = fname; alumn.Lname = lname; alumn.Password = password; alumn.Email = email; businessManager.CreateAlumnus(alumn); }
// Add booking and SendList public bool CreateBooking(int ActivityId) //form 3 { Alumnus alumnusX = unitOfWork.Alumnuses.GetAlumnusActivity(PersonOnline.ID); Activity activityX = unitOfWork.Activities.Get(ActivityId); if (!alumnusX.Activities.Contains(activityX)) { alumnusX.Activities.Add(activityX); unitOfWork.Save(); return(true); } return(false); }
public ActionResult DeleteConfirmed(int id) { if (Session["userName"] != null) { Alumnus alumnus = db.Alumni.Find(id); db.Alumni.Remove(alumnus); db.SaveChanges(); return(RedirectToAction("Index")); } else { return(RedirectToAction("Logout", "Admin")); } }
// GET: Alumni/Details/5 public ActionResult Details(int?id) { if (Session["userName"] != null) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Alumnus alumnus = db.Alumni.Find(id); if (alumnus == null) { return(HttpNotFound()); } return(View(alumnus)); } else { return(RedirectToAction("Logout", "Admin")); } }
private void CreateAlumnus() { List <string> vs1 = new List <string>() { Firstname, Lastname, PersonCode, Email, PhoneNumber, Qualification, ExamDate, Password, Confirm }; if (!vs1.Contains(string.Empty)) { bool Accepted1 = int.TryParse(this.PhoneNumber, out int Phonenumber); bool Accepted2 = DateTime.TryParse(this.ExamDate, out DateTime ExamDate); List <bool> vs2 = new List <bool> { Accepted1, Accepted2, Consent }; if (!vs2.Contains(false) && Password == Confirm) { Alumnus alumnus = new Alumnus(); alumnus.Fname = Firstname; alumnus.Lname = Lastname; alumnus.PersonCode = PersonCode; alumnus.Email = Email; alumnus.PhoneNumber = Phonenumber; alumnus.Qualification = Qualification; alumnus.ExamDate = ExamDate; alumnus.Password = Password; UnitOfWork.Alumnuses.Add(alumnus); UnitOfWork.Save(); CloseView(); } else { Information = "Something whent wrong"; OnPropertyChanged("Information"); } } else { Information = "Make sure you filled everything in"; OnPropertyChanged("Information"); } }
/// <summary> /// Bestätigung als Almuni eines Studiengangs /// </summary> /// <param name="id">Student</param> /// <returns></returns> public ActionResult Accept(Guid id) { // Das kann nur der aktuelle user für sich var user = GetCurrentUser(); var student = Db.Students.SingleOrDefault(x => x.Id == id); if (!user.Id.Equals(student.UserId)) { return(View("_NoAccess")); } // Check gibt es dazu schon einen Alumni // Link über die user id var alumni = Db.Alumnae.SingleOrDefault(x => x.UserId.Equals(student.UserId) && x.Curriculum.Id == student.Curriculum.Id); // Standard: es gibt den alumni noch nicht if (alumni == null) { // anlegen, aber nicht speichern alumni = new Alumnus { Curriculum = student.Curriculum, Semester = student.LastSemester }; } var model = new AlumniViewModel { Student = student, Alumni = alumni }; return(View(model)); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Move all the code in Page_Load inside this block to avoid Invalid Postbacks //Temporary data for presentation to client List <Alumnus> alumni = new List <Alumnus>(); Alumnus alumnus1 = new Alumnus("John", "Doe", "987654321", DateTime.Now.AddMonths(8).ToString("MM/dd/yyyy"), DateTime.Now.AddDays(-30).ToString("MM/dd/yyyy")); Alumnus alumnus2 = new Alumnus("Jane", "Doe", "987654322", DateTime.Now.AddMonths(8).ToString("MM/dd/yyyy"), DateTime.Now.AddDays(-20).ToString("MM/dd/yyyy")); Alumnus alumnus3 = new Alumnus("Bob", "Smith", "987654332", DateTime.Now.AddMonths(8).ToString("MM/dd/yyyy"), DateTime.Now.AddDays(-10).ToString("MM/dd/yyyy")); Alumnus alumnus4 = new Alumnus("Mary", "Smith", "987654432", DateTime.Now.AddMonths(8).ToString("MM/dd/yyyy"), DateTime.Now.AddDays(-5).ToString("MM/dd/yyyy")); for (int i = 0; i < 3; i++) { alumni.Add(alumnus1); alumni.Add(alumnus2); alumni.Add(alumnus3); alumni.Add(alumnus4); } gvAlumni.DataSource = alumni; gvAlumni.DataBind(); } }
private void buttonChange_Click(object sender, EventArgs e) { IAlumnus temporaryalumn = new Alumnus(); if (listView1.SelectedItems.Count > 0) { string OldPersonCode = listView1.SelectedItems[0].Text; bool Accept1 = int.TryParse(textBoxPhonenumber.Text, out int Phonenumber); bool Accept2 = DateTime.TryParse(textBoxExamDate.Text, out DateTime Examdate); List <bool> Accepts = new List <bool> { Accept1, Accept2 }; if (!Accepts.Contains(false)) { temporaryalumn.Fname = textBoxFname.Text; temporaryalumn.Lname = textBoxLname.Text; temporaryalumn.PersonCode = textBoxPersonCode.Text; temporaryalumn.Qualification = textBoxQuali.Text; temporaryalumn.Email = textBoxEmail.Text; temporaryalumn.PhoneNumber = Phonenumber; temporaryalumn.ExamDate = Examdate; BusinessManager.ChangeAlumnus2(temporaryalumn, OldPersonCode); StartUpdate(); } } textBoxFname.Text = string.Empty; textBoxLname.Text = string.Empty; textBoxPersonCode.Text = string.Empty; textBoxQuali.Text = string.Empty; textBoxEmail.Text = string.Empty; textBoxPhonenumber.Text = string.Empty; textBoxExamDate.Text = string.Empty; }
public ActionResult Edit(Alumnus alumnus, HttpPostedFileBase ImageFile) { if (Session["userName"] != null) { if (ImageFile != null) { using (var ms = new MemoryStream()) { ImageFile.InputStream.CopyTo(ms); alumnus.Image = ms.ToArray(); } if (ModelState.IsValid) { db.Entry(alumnus).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } } else { if (ModelState.IsValid) { alumnus.Name = alumnus.Name; db.Entry(alumnus).State = EntityState.Modified; db.Entry(alumnus).Property(x => x.Image).IsModified = false; db.SaveChanges(); return(RedirectToAction("Index")); } } return(View(alumnus)); } else { return(RedirectToAction("Logout", "Admin")); } }
public ActionResult Create(Alumnus alumnus, HttpPostedFileBase ImageFile) { if (Session["userName"] != null) { using (var ms = new MemoryStream()) { ImageFile.InputStream.CopyTo(ms); alumnus.Image = ms.ToArray(); } if (ModelState.IsValid) { db.Alumni.Add(alumnus); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(alumnus)); } else { return(RedirectToAction("Logout", "Admin")); } }
public ActionResult SendInvitations(OccurrenceMailingModel model) { var host = AppUser; var invitationList = Session["InvitationList"] as InvitationCheckModel; var semSubService = new SemesterSubscriptionService(); if (invitationList == null) { return(View("SendInvitationsError")); } var attachmentList = new List <CustomMailAttachtmentModel>(); foreach (var attachment in model.Attachments) { if (attachment != null) { var bytes = new byte[attachment.ContentLength]; attachment.InputStream.Read(bytes, 0, attachment.ContentLength); attachmentList.Add(new CustomMailAttachtmentModel { FileName = Path.GetFileName(attachment.FileName), Bytes = bytes, }); } } foreach (var invitation in invitationList.Invitations.Where(i => i.Invite)) { invitation.Invited = false; var now = DateTime.Now; var newUser = false; if (invitation.User == null) { var user = new ApplicationUser { UserName = invitation.Email, Email = invitation.Email, FirstName = invitation.FirstName, LastName = invitation.LastName, Registered = now, MemberState = MemberState.Guest, Remark = "Einladung von " + host.FullName, ExpiryDate = null, // Einladung bleibt dauerhaft bestehen - Deprovisionierung automatisch Submitted = now, EmailConfirmed = true, // damit ist auch ein "ForgotPassword" möglich, auch wenn er die Einladung nicht angenommen hat. IsApproved = true, // Damit bekommt der Nutzer von Anfang an E-Mails Faculty = host.Id // Benutzer der eingeladen hat }; // Benutzer anlegen, mit Dummy Passwort var result = UserManager.Create(user, "Pas1234?"); if (result.Succeeded) { invitation.User = user; newUser = true; } else { foreach (var error in result.Errors) { invitation.Remark += error; } } } if (invitation.User != null) { // Eintrag in Alumni Tabelle - nur falls es ihn noch nicht gibt var curr = Db.Curricula.SingleOrDefault(c => c.ShortName.Equals(invitation.Curriculum.Trim())); var sem = Db.Semesters.SingleOrDefault(s => s.Name.Equals(invitation.Semester)); if (!Db.Alumnae.Any(a => a.Curriculum.Id == curr.Id && a.Semester.Id == sem.Id && a.UserId.Equals(invitation.User.Id))) { var alumnus = new Alumnus { UserId = invitation.User.Id, Curriculum = curr, Semester = sem }; Db.Alumnae.Add(alumnus); Db.SaveChanges(); } // nur neue Benutzer bekommen eine E-Mail // analog Forget E-Mail Versand string code = UserManager.GeneratePasswordResetToken(invitation.User.Id); var mailModel = new ForgotPasswordMailModel { User = invitation.User, Token = code, CustomSubject = model.Subject, CustomBody = model.Body, Attachments = attachmentList, IsNewAccount = newUser }; try { new MailController().InvitationMail(mailModel, host, "de").Deliver(); invitation.Invited = true; } catch (SmtpFailedRecipientException ex) { invitation.Remark = ex.Message; } } } var deliveryMailModel = new GenericMailDeliveryModel { Subject = model.Subject, Receiver = host, TemplateContent = new UserMailModel { CustomBody = model.Body, } }; // Mail an Einladenden versenden var ms = new MemoryStream(); var writer = new StreamWriter(ms, Encoding.Default); writer.Write( "Name;Vorname;E-Mail;Versand;Bemerkung"); writer.Write(Environment.NewLine); foreach (var delivery in invitationList.Invitations) { writer.Write("{0};{1};{2};{3};{4}", delivery.LastName, delivery.FirstName, delivery.Email, (delivery.Invite && delivery.Invited) ? "OK" : "FEHLER", delivery.Remark); writer.Write(Environment.NewLine); } writer.Flush(); writer.Dispose(); var sb = new StringBuilder(); sb.Append("Versandbericht"); sb.Append(".csv"); deliveryMailModel.Attachments.Add(new CustomMailAttachtmentModel { FileName = sb.ToString(), Bytes = ms.GetBuffer() }); try { new MailController().GenericMail(deliveryMailModel).Deliver(); } catch (Exception ex) { var logger = LogManager.GetLogger("SendMail"); logger.ErrorFormat("Mailsent failed: {0}", ex.Message); } return(View("SendInvitationsSuccess", invitationList)); }
public void CreateAlumnus(Alumnus alumnus) { UnitOfWork.alumnus.Add(alumnus); UnitOfWork.Compelte(); }
public void Add(DataContext dataContext) { //Employees Employee employee1 = new Employee() { Fname = "Gabriel", Lname = "Lundberg Puglia", PersonCode = "19961106-9999", Password = "******", Email = "*****@*****.**", PhoneNumber = 0706555233, EmployeerDate = new DateTime(2019, 03, 04), Activities = new List <Activity>(), SendLists = new List <SendList>() }; dataContext.Employees.Add(employee1); Employee employee2 = new Employee() { Fname = "Olle", Lname = "Sandahl", PersonCode = "19960306-9999", Password = "******", Email = "*****@*****.**", PhoneNumber = 0706555768, EmployeerDate = new DateTime(2018, 08, 04), Activities = new List <Activity>(), SendLists = new List <SendList>() }; dataContext.Employees.Add(employee2); // Alumnuses Alumnus alumnus1 = new Alumnus() { Fname = "Lindah", Lname = "Dahl", PersonCode = "19860302-9999", Password = "******", Email = "*****@*****.**", PhoneNumber = 0708555788, Qualification = "DataEkonomutbildningen", ExamDate = new DateTime(2020, 03, 12), }; dataContext.Alumnuses.Add(alumnus1); Alumnus alumnus2 = new Alumnus() { Fname = "Robin", Lname = "Sten", PersonCode = "19790302-9999", Password = "******", Email = "*****@*****.**", PhoneNumber = 0708666711, Qualification = "DataEkonomutbildningen", ExamDate = new DateTime(2019, 03, 12), }; dataContext.Alumnuses.Add(alumnus2); Alumnus alumnus3 = new Alumnus() { Fname = "Daniel", Lname = "White", PersonCode = "19990302-9999", Password = "******", Email = "*****@*****.**", PhoneNumber = 0708666711, Qualification = "Systemvetarutbildning", ExamDate = new DateTime(2019, 03, 12), }; dataContext.Alumnuses.Add(alumnus3); Alumnus alumnus4 = new Alumnus() { Fname = "Erik", Lname = "White", PersonCode = "19990302-9999", Password = "******", Email = "*****@*****.**", PhoneNumber = 0708666711, Qualification = "Systemvetarutbildning", ExamDate = new DateTime(2019, 03, 12), }; dataContext.Alumnuses.Add(alumnus4); Alumnus alumnus5 = new Alumnus() { Fname = "Sara", Lname = "Sol", PersonCode = "19860302-9999", Password = "******", Email = "*****@*****.**", PhoneNumber = 0708666711, Qualification = "Textilekonom", ExamDate = new DateTime(2019, 03, 12), }; dataContext.Alumnuses.Add(alumnus5); Alumnus alumnus6 = new Alumnus() { Fname = "Stina", Lname = "Lima", PersonCode = "19950302-9999", Password = "******", Email = "*****@*****.**", PhoneNumber = 0708668866, Qualification = "Textilekonom", ExamDate = new DateTime(2019, 03, 12), }; dataContext.Alumnuses.Add(alumnus6); //Aktivitis Activity activity1 = new Activity() { Event = "Introduktion", Adress = "Allégatan 1, 503 32 Borås", Date = new DateTime(2020, 04, 01, 10, 30, 00), Category = "Möte", Alumnuses = new List <Alumnus>(), Employee = employee1 }; activity1.Alumnuses.Add(alumnus1); activity1.Alumnuses.Add(alumnus2); activity1.Alumnuses.Add(alumnus5); dataContext.Activities.Add(activity1); Activity activity2 = new Activity() { Event = "Invignings Fest", Adress = "Allégatan 1, 503 32 Borås", Date = new DateTime(2020, 04, 01, 18, 30, 00), Category = "Nöje", Alumnuses = new List <Alumnus>(), Employee = employee2 }; activity1.Alumnuses.Add(alumnus3); activity1.Alumnuses.Add(alumnus4); activity1.Alumnuses.Add(alumnus6); dataContext.Activities.Add(activity2); // SendLists SendList sendList1 = new SendList() { Name = "Dataekonomer", Alumnuses = new List <Alumnus>(), Employee = employee1 }; sendList1.Alumnuses.Add(alumnus1); sendList1.Alumnuses.Add(alumnus2); dataContext.SendLists.Add(sendList1); SendList sendList2 = new SendList() { Name = "Systemvetare", Alumnuses = new List <Alumnus>(), Employee = employee1 }; sendList1.Alumnuses.Add(alumnus4); sendList1.Alumnuses.Add(alumnus3); dataContext.SendLists.Add(sendList2); SendList sendList3 = new SendList() { Name = "Textilekonomer", Alumnuses = new List <Alumnus>(), Employee = employee2 }; sendList1.Alumnuses.Add(alumnus5); sendList1.Alumnuses.Add(alumnus6); dataContext.SendLists.Add(sendList3); dataContext.SaveChanges(); }
public void UpdateAlumn(Alumnus newAlumn) { UnitOfWork.person.Remove(logIn); UnitOfWork.alumnus.Add(newAlumn); Complete(); }