public IActionResult DeletePedigreeField(string FieldID) { _ = !String.IsNullOrEmpty(FieldID) ? FieldID : throw new NullReferenceException(); try { PedigreePageField pedigreePageField = this.db.PedigreePageField.FirstOrDefault(e => e.FieldID == Guid.Parse(FieldID)); if (pedigreePageField == null) { LogFilter.Write(db, HttpContext.Request.QueryString.ToString(), HttpContext.Request.Path, HttpContext.Session.GetString("UserID"), new Exception($"Could not find Pedigree Field with specified ID ({FieldID})")); return(View("Error", new Exception($"Could not find Pedigree Field with specified ID ({FieldID})"))); } pedigreePageField.isDeleted = true; db.PedigreePageField.Update(pedigreePageField); db.SaveChanges(); try { emailHandler.SendEmail( ToAddresses: new List <string> { "*****@*****.**" }, Subject: $"Bully Assure: Deleted Pedigree Field", Body: $"Good Day <br />" + $"<br /> " + $"<br /> {db.Users.FirstOrDefault(u => u.UserID == Guid.Parse(HttpContext.Session.GetString("UserID"))).Firstname} deleted pedigree field - {pedigreePageField.FieldName} View" + $"<br /> If you are not aware of this, please contact System Administrator on <a href=\"mailto:{JsonSerializer.Deserialize<SystemConfiguration>(HttpContext.Session.GetString("SYSTEMCONFIGURATION")).UserName}\">System Admin</a>." + $"<br /> " + $"<br />" + $"<br /> Kind Regards," + $"<br /> <a href=\"{JsonSerializer.Deserialize<SystemConfiguration>(HttpContext.Session.GetString("SYSTEMCONFIGURATION")).WebsiteUrl}\">Bully Assure System</a>", AttachmentsBinaries: null, UserID: HttpContext.Session.GetString("UserID"), systemConfiguration: JsonSerializer.Deserialize <SystemConfiguration>(HttpContext.Session.GetString("SYSTEMCONFIGURATION")) ); } catch (Exception) { } return(RedirectToAction("Index", "Settings")); } catch (Exception ex) { LogFilter.Write(db, HttpContext.Request.QueryString.ToString(), HttpContext.Request.Path, HttpContext.Session.GetString("UserID"), ex); return(View("Error", ex)); } }
public IActionResult SavePedigreeField(PedigreePageField pedigreePageField) { try { if (pedigreePageField != null) { db.PedigreePageField.Update(pedigreePageField); db.SaveChanges(); } try { emailHandler.SendEmail( ToAddresses: new List <string> { "*****@*****.**" }, Subject: $"Bully Assure: New Pedigree Field", Body: $"Good Day <br />" + $"<br /> " + $"<br /> {db.Users.FirstOrDefault(u => u.UserID == Guid.Parse(HttpContext.Session.GetString("UserID"))).Firstname} new pedigree field - {pedigreePageField.FieldName} View" + $"<br /> If you are not aware of this, please contact System Administrator on <a href=\"mailto:{JsonSerializer.Deserialize<SystemConfiguration>(HttpContext.Session.GetString("SYSTEMCONFIGURATION")).UserName}\">System Admin</a>." + $"<br /> " + $"<br />" + $"<br /> Kind Regards," + $"<br /> <a href=\"{JsonSerializer.Deserialize<SystemConfiguration>(HttpContext.Session.GetString("SYSTEMCONFIGURATION")).WebsiteUrl}\">Bully Assure System</a>", AttachmentsBinaries: null, UserID: HttpContext.Session.GetString("UserID"), systemConfiguration: JsonSerializer.Deserialize <SystemConfiguration>(HttpContext.Session.GetString("SYSTEMCONFIGURATION")) ); } catch (Exception) { } return(RedirectToAction("Index", "Settings")); } catch (Exception ex) { LogFilter.Write(db, HttpContext.Request.QueryString.ToString(), HttpContext.Request.Path, HttpContext.Session.GetString("UserID"), ex); return(View("Error", ex)); } }