/** * Test that overriding equals works as expected */ public void testEqualsOverride() { String assertedValue = "FOO"; AddressType testEnum = AddressType.Wrap(assertedValue); // objects should be reflexively equal to themselves Assert.IsTrue(testEnum.Equals(testEnum), "Reflexive comparison should pass"); // test with null comparison Assert.IsFalse(testEnum.Equals(null), "Null comparison should fail"); AddressType testEnum2 = AddressType.Wrap(assertedValue); Assert.IsTrue(testEnum.Equals(testEnum2)); Assert.IsTrue(testEnum2.Equals(testEnum)); // Test with a different enum value AddressType testEnum3 = AddressType.MAILING; Assert.IsFalse(testEnum3.Equals(testEnum)); Assert.IsFalse(testEnum.Equals(testEnum3)); // Test with a different enum type, but same value EmailType differentEnum = EmailType.Wrap(assertedValue); Assert.IsFalse(differentEnum.Equals(testEnum)); Assert.IsFalse(testEnum.Equals(differentEnum)); // Test with two null values AddressType nullEnum = AddressType.Wrap(null); AddressType nullEnum2 = AddressType.Wrap(null); Assert.IsTrue(nullEnum.Equals(nullEnum2), "Two Enums with null values should match"); Assert.IsFalse(nullEnum.Equals(testEnum)); Assert.IsFalse(testEnum.Equals(null)); }
//public async Task<IQueryable<UserModuleImage>> GetUserModuleImageByModuleId(int moduleId, int userId, int facultyId) //{ // return await Task.Run(() => // { // return _contex.UserModuleImages.Where(m => m.UserId == userId && m.ModulId == moduleId && m.Faculty_Id == facultyId); // }); //} public void SendMail(string toAddress, EmailType emailType, string guid, string bodyData = "", string subjectData = "") { MailMessage message = new MailMessage(); SmtpClient smtpClient = new SmtpClient(); string smtpHost = ConfigurationManager.AppSettings["SmtpHost"].ToString(); string smtpUser = ConfigurationManager.AppSettings["SmtpUser"].ToString(); string smtpPassword = ConfigurationManager.AppSettings["SmtpPassword"].ToString(); string subject = string.Empty; string body = string.Empty; string mailUrl = string.Empty; try { if (emailType.Equals(EmailType.TalkAccess) | emailType.Equals(EmailType.TalkRevoked)) { message.From = new MailAddress(ConfigurationManager.AppSettings["SmtpUser"].ToString()); message.To.Add(toAddress); string copy = ConfigurationManager.AppSettings["supportEmail"].ToString(); message.CC.Add(copy); } if (emailType.Equals(EmailType.AcceptImage) | emailType.Equals(EmailType.RejectImage)) { message.From = new MailAddress(ConfigurationManager.AppSettings["SmtpUser"].ToString()); message.To.Add(toAddress); string copy = ConfigurationManager.AppSettings["supportEmail"].ToString(); message.CC.Add(copy); } message.IsBodyHtml = true; message.Headers.Add("Content-Type", "content=text/html; charset=\"UTF-8\""); switch (emailType) { case EmailType.TalkAccess: subject = "Talk Access - Grant"; mailUrl = "Talk Access"; body = bodyData; break; case EmailType.TalkRevoked: subject = "Talk Access - Revoke"; mailUrl = "Talk Access"; body = bodyData; break; case EmailType.AcceptImage: subject = "Image submission - accepted"; mailUrl = "image accepted"; body = bodyData; break; case EmailType.RejectImage: subject = "Image submission - rejected"; mailUrl = "image rejected"; body = bodyData; break; default: break; } message.Subject = subject; message.Body = body; smtpClient.Host = smtpHost; // We use gmail as our smtp client smtpClient.Port = 2525; smtpClient.Credentials = new System.Net.NetworkCredential(smtpUser, smtpPassword); if (!string.IsNullOrWhiteSpace(subject) && !string.IsNullOrWhiteSpace(body) && !string.IsNullOrWhiteSpace(mailUrl)) { smtpClient.Send(message); } } catch { throw; } }