Created
March 11, 2023 06:12
-
-
Save profesor79/6921d7396e505541687f735197b56abc to your computer and use it in GitHub Desktop.
see this and cry, cry loudly to the heavens
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost] | |
public HttpResponseMessage UpdateSomething(Parameters parameters) | |
{ | |
_logger.Debug("some useful info here"); | |
try | |
{ | |
var response = new HttpResponseMessage(); | |
var eletran = ctx.ElementTransactions.Where(s => s.ElementNo == parameters.ElementId).First(); | |
if (eletran != null && eletran.ElementNo > 0) | |
{ | |
var dt = DateTime.Parse(eletran.DocumentPeriod + "-01"); | |
var documentPeriod = string.IsNullOrWhiteSpace(eletran.DocumentPeriodType) ? $"{dt:MMM}-{dt:yy}" : $"{dt:MMM}-{dt:yy} {eletran.DocumentPeriodType}"; | |
var inv = ctx.Elements.Where(s => s.ElementNo == parameters.ElementId).ToList(); | |
var minTableName = ctx.TableName.Where(s => s.ElementId == parameters.ElementId).FirstOrDefault(); | |
if (minTableName == null) | |
{ | |
response.StatusCode = HttpStatusCode.OK; | |
response.Content = new StringContent("REDACTED"); | |
} | |
else if (inv.Count > 0) | |
{ | |
response.StatusCode = HttpStatusCode.OK; | |
response.Content = new StringContent("WTF REPEATING STRING."); | |
} | |
else if (minTableName.ElementId > 0) | |
{ | |
if (minTableName.Entity == eletran.Customer && minTableName.Month != documentPeriod) | |
{ | |
response.StatusCode = HttpStatusCode.OK; | |
response.Content = new StringContent("REDACTED"); | |
} | |
else if (minTableName.Entity != eletran.Customer && minTableName.Month == documentPeriod) | |
{ | |
response.StatusCode = HttpStatusCode.OK; | |
response.Content = new StringContent("REDACTED"); | |
} | |
else if (minTableName.Entity != eletran.Customer && minTableName.Month != documentPeriod) | |
{ | |
response.StatusCode = HttpStatusCode.OK; | |
response.Content = new StringContent("REDACTED"); | |
} | |
else if (inv.Count == 0 && minTableName.Entity == eletran.Customer && minTableName.Month == documentPeriod) | |
{ | |
eletran.TranStatus = "Manually Generated"; | |
eletran.ElementNo = parameters.ElementId; | |
ctx.SaveChanges(); | |
response.StatusCode = HttpStatusCode.OK; | |
} | |
else | |
{ | |
response.StatusCode = HttpStatusCode.OK; | |
response.Content = new StringContent("WTF REPEATING STRING."); | |
} | |
} | |
else | |
{ | |
response.StatusCode = HttpStatusCode.OK; | |
response.Content = new StringContent("WTF REPEATING STRING."); | |
} | |
} | |
else | |
{ | |
response.StatusCode = HttpStatusCode.OK; | |
response.Content = new StringContent("Data not found."); | |
} | |
return response; | |
} | |
catch (Exception ex) | |
{ | |
_logger.Error(ex); | |
var response = new HttpResponseMessage(); | |
response.StatusCode = HttpStatusCode.InternalServerError; | |
return response; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment