protected int EditParticipants(ICollection <Participant> Participants, int Lab_ID) { ApplicationDbContext db = new ApplicationDbContext(); db.LabParticipants.Where(p => p.LabID == Lab_ID).ToList().ForEach(p => db.LabParticipants.Remove(p)); if (Participants != null) { foreach (Participant participant in Participants) { if (participant.Username != null) { LabParticipant labParticipant = new LabParticipant(); labParticipant.Email_Address = participant.Username.Trim(); if (participant.First_Name != null) { labParticipant.First_Name = participant.First_Name.Trim(); } if (participant.Last_Name != null) { labParticipant.Last_Name = participant.Last_Name.Trim(); } labParticipant.Role = participant.Role.Trim(); labParticipant.LabID = Lab_ID; db.LabParticipants.Add(labParticipant); } } } db.SaveChanges(); return(0); }
public JsonResult GetMachineLink(int Participant_ID, int Lab_ID) { ApplicationDbContext db = new ApplicationDbContext(); LabParticipant participant = db.LabParticipants.Where(p => p.ID == Participant_ID && p.LabID == Lab_ID).FirstOrDefault(); Lab lab = db.Labs.Where(l => l.ID == Lab_ID).FirstOrDefault(); string UserName = User.Identity.Name; string MachineLink = "http://ijpie.azurewebsites.net/" + UserName + "/" + lab.Name + "/" + participant.Email_Address.Replace("@", "_"); return(Json(new { Status = 0, Message = MachineLink })); }
public JsonResult SendMachineLink(int Participant_ID, int Lab_ID) { ApplicationDbContext db = new ApplicationDbContext(); LabParticipant participant = db.LabParticipants.Where(p => p.ID == Participant_ID && p.LabID == Lab_ID).FirstOrDefault(); Lab lab = db.Labs.Where(l => l.ID == Lab_ID).FirstOrDefault(); string UserName = User.Identity.Name; string link = "http://ijpie.azurewebsites.net/" + UserName + "/" + lab.Name + "/" + participant.Email_Address.Replace("@", "_"); Mailer mail = new Mailer("*****@*****.**", "ijpie"); mail.Compose(link, participant.Email_Address); mail.SendMail(); return(Json(new { Status = 0 })); }
public JsonResult MoveParticipant(int Participant_ID, int Lab_ID, int newLab_ID, string todo) { ApplicationDbContext db = new ApplicationDbContext(); var participant = db.LabParticipants.Where(p => p.ID == Participant_ID && p.LabID == Lab_ID).FirstOrDefault(); LabParticipant participantCp = participant; participant.LabID = newLab_ID; if (todo == "Move") { db.LabParticipants.Remove(participant); db.SaveChanges(); } db.LabParticipants.Add(participantCp); db.SaveChanges(); return(Json(new { Status = 0, prevLab = "lab-" + Lab_ID, newLab = "lab-" + newLab_ID })); }