public static async Task <Result> Save(string site, Models.ProfessionalTranslator.Net.Log.Exception inputItem) { var messages = new List <string>(); if (inputItem == null) { return(new Result(ResultStatus.Failed, "Exception cannot be null.")); } Tables.dbo.Site siteItem = await dbRead.Site.Item(site); if (siteItem == null) { return(new Result(ResultStatus.Failed, "No site was found with that name.")); } if (string.IsNullOrEmpty(inputItem.Message)) { messages.Add("Message cannot be empty."); } if (string.IsNullOrEmpty(inputItem.Type)) { messages.Add("Type cannot be empty."); } if (string.IsNullOrEmpty(inputItem.Class)) { messages.Add("Class cannot be empty."); } else if (inputItem.Class.Length > 2048) { messages.Add("Class must be 2048 characters or fewer."); } if (messages.Any()) { return(new Result(ResultStatus.Failed, messages)); } var convertItem = new Tables.Log.Exception { Id = inputItem.Id, SiteId = siteItem.Id, Message = inputItem.Message, Stacktrace = inputItem.Stacktrace, Type = inputItem.Type, Class = inputItem.Class, DateCreated = inputItem.DateCreated ?? DateTime.Now }; Result saveResult = await dbWrite.Item(site, convertItem); return(saveResult); }
public static async Task <Models.ProfessionalTranslator.Net.Log.Exception> Item(Guid id) { Tables.Log.Exception exception = await dbReadLog.Item(id); if (exception == null) { return(null); } var output = new Models.ProfessionalTranslator.Net.Log.Exception { Id = exception.Id, Message = exception.Message, Stacktrace = exception.Stacktrace, Type = exception.Type, Class = exception.Class, DateCreated = exception.DateCreated }; return(output); }