private string ValidateReturn(ProductKeyInfo key, ReturnReport returnReport, ReturnReportKey returnReportKey) { if (!returnReport.ReturnNoCredit) { return "OJ"; } else { if (key == null) return "PB"; else if (key.ProductKeyStateID == 5) return "PF"; else return "QK"; } }
private void FixupReturnReport(ReturnReport previousValue) { if (previousValue != null && previousValue.ReturnReportKeys.Contains(this)) { previousValue.ReturnReportKeys.Remove(this); } if (ReturnReport != null) { if (!ReturnReport.ReturnReportKeys.Contains(this)) { ReturnReport.ReturnReportKeys.Add(this); } if (ReturnUniqueID != ReturnReport.ReturnUniqueID) { ReturnUniqueID = ReturnReport.ReturnUniqueID; } } }
public Guid ReportReturn(ReturnReport returnReport) { Guid returnUniqueID = Guid.NewGuid(); List<ReturnReportKey> returnReportKeys = returnReport.ReturnReportKeys.ToList(); using (var db = GetContext()) { List<ProductKeyInfo> dbKeys = GetProductKeyInfoes(db, returnReportKeys.Select(k => k.ProductKeyID).ToList()); int i = 1; returnReportKeys.ForEach(returnReportKey => { ProductKeyInfo productKeyInfo = dbKeys.Single(k => k.ProductKeyID == returnReportKey.ProductKeyID); productKeyInfo.ProductKeyStateID = 5; string reasonCode = ValidateReturn(productKeyInfo, returnReport, returnReportKey); returnReportKey.ReturnReasonCode = reasonCode; returnReportKey.ReturnReasonCodeDescription = GetReturnReasonCodeDescription(reasonCode); returnReportKey.LicensablePartNumber = productKeyInfo.LicensableName; returnReportKey.MSReturnLineNumber = i++; }); returnReport.ReturnUniqueID = returnUniqueID; returnReport.MSReturnNumber = GetMaxMSReturnNumber(db).ToString(); returnReport.ReturnDateUTC = DateTime.UtcNow; returnReport.OEMRMADateUTC = DateTime.UtcNow; returnReport.status = true; db.ReturnReports.AddObject(returnReport); db.SaveChanges(); return returnUniqueID; } }