public static void DeleteResearchTable() { using (OpidDB opidcontext = new OpidDB()) { opidcontext.RChecks.RemoveRange(opidcontext.RChecks); // Remove all checks from table RChecks (the Research Table) opidcontext.SaveChanges(); return; } }
public static Invitation AcceptedInvitation(string userName, string email) { using (OpidDB opidcontext = new OpidDB()) { Invitation invite = opidcontext.Invitations.Where(i => i.UserName == userName).SingleOrDefault(); if (invite != null && invite.Email == email) { invite.Accepted = DateTime.Today; opidcontext.SaveChanges(); return(invite); } return(null); } }
private static void AppendToResearchChecks(List <Check> checks) { try { using (OpidDB opidcontext = new OpidDB()) { foreach (Check check in checks) { RCheck existing = opidcontext.RChecks.Where(u => u.Num == check.Num).FirstOrDefault(); if (existing == null) // && string.IsNullOrEmpty(check.Clr)) { RCheck rcheck = new RCheck { RecordID = check.RecordID, sRecordID = check.RecordID.ToString(), InterviewRecordID = check.InterviewRecordID, sInterviewRecordID = check.InterviewRecordID.ToString(), Num = check.Num, sNum = check.Num.ToString(), Name = check.Name, Date = check.Date, sDate = check.Date.ToString("MM/dd/yyyy"), Service = check.Service, Disposition = check.Disposition, }; opidcontext.RChecks.Add(rcheck); } else if (!string.IsNullOrEmpty(check.Disposition)) { // The existing check may have its disposition // changed to, for example, Voided/Replaced. // If a file of voided checks contains a check with number existing.Num // then this change of disposition will protect this check from having its status // in Apricot changed from Voided/Replaced to Voided existing.Disposition = check.Disposition; } } opidcontext.SaveChanges(); } } catch (Exception e) { } }
public static void MarkMistakenlyResolvedChecks(List <Check> mistakenlyResolved) { using (OpidDB opidcontext = new OpidDB()) { foreach (Check mr in mistakenlyResolved) { List <RCheck> rchecks = opidcontext.RChecks.Where(u => u.Num == mr.Num).ToList(); foreach (RCheck rcheck in rchecks) { rcheck.Disposition = "Mistakenly Resolved"; } } opidcontext.SaveChanges(); } }
public static string EditUser(InvitationViewModel invite) { using (OpidDB referralscontext = new OpidDB()) { Invitation invitation = referralscontext.Invitations.Find(invite.Id); if (invitation != null && invitation.Accepted != (System.DateTime)System.Data.SqlTypes.SqlDateTime.Null) { return("Registered"); } invitation.UserName = invite.UserName; invitation.Email = invite.Email; invitation.Role = invite.Role; referralscontext.SaveChanges(); return("Success"); } }
public static void ResolveResearchChecks() { using (OpidDB opidcontext = new OpidDB()) { var researchChecks = opidcontext.RChecks; foreach (CheckViewModel check in resolvedChecks) { List <RCheck> rchecks = researchChecks.Where(u => u.Num == check.Num || u.Num == -check.Num).ToList(); foreach (RCheck rcheck in rchecks) { rcheck.Disposition = check.Disposition; } } opidcontext.SaveChanges(); } }
/* * private static void SendEmailInvitation(InvitationViewModel invitation) * { * var message = new MailMessage(); * message.To.Add(new MailAddress(invitation.Email)); * message.From = new MailAddress(ConfigurationManager.AppSettings["DonotreplyEmailAddr"]); * message.Subject = "Invitation"; * message.Body = InvitationMessage(invitation); * message.IsBodyHtml = true; * * using (var smtp = new SmtpClient()) * { * var credential = new NetworkCredential * { * UserName = ConfigurationManager.AppSettings["GmailUser"], * Password = ConfigurationManager.AppSettings["GmailUserPassword"] * }; * * smtp.Credentials = credential; * smtp.Host = "smtp.gmail.com"; * smtp.Port = 587; * smtp.EnableSsl = true; * smtp.Send(message); * } * } */ public static void ExtendInvitation(InvitationViewModel invitation) { using (OpidDB opidcontext = new OpidDB()) { Invitation invite = new Invitation { Extended = DateTime.Today, Accepted = (System.DateTime)System.Data.SqlTypes.SqlDateTime.Null, UserName = invitation.UserName, FullName = invitation.FullName, Email = invitation.Email, Role = invitation.Role, }; opidcontext.Invitations.Add(invite); opidcontext.SaveChanges(); } // SendEmailInvitation(invitation); }
public async Task <string> DeleteUser(int id) { using (OpidDB opidcontext = new OpidDB()) { Invitation invite = opidcontext.Invitations.Where(i => i.Id == id).SingleOrDefault(); if (invite != null) { var user = await UserManager.FindByNameAsync(invite.UserName); if (user != null) { UserManager.Delete(user); opidcontext.Invitations.Remove(invite); opidcontext.SaveChanges(); return("Success"); } } return("Failure"); } }
private static void RestoreRChecksTable(List <CheckViewModel> rChecks) { using (OpidDB opidcontext = new OpidDB()) { var checks = opidcontext.RChecks; int checkCount = rChecks.Count; int i = 0; if (checks.Count() == 0) // Is the table empty for rebuild? { foreach (CheckViewModel rc in rChecks) { checks.Add(new RCheck { RecordID = rc.RecordID, sRecordID = rc.sRecordID, InterviewRecordID = rc.InterviewRecordID, sInterviewRecordID = rc.sInterviewRecordID, Num = rc.Num, sNum = rc.sNum, Name = rc.Name, Date = Convert.ToDateTime(rc.Date), sDate = Convert.ToDateTime(rc.Date).ToString("MM/dd/yyyy"), Service = rc.Service, Disposition = rc.Disposition }); i += 1; ProgressHub.SendProgress("Restore in progress...", i, checkCount); } opidcontext.SaveChanges(); return; } } }