public IActionResult Post([FromBody] CashJournal entity) { IActionResult ret = null; try { if (entity != null) { using (var db = new BTAContext()) { db.CashJournal.Add(entity); db.SaveChanges(); ret = StatusCode(StatusCodes.Status201Created, entity); } } else { ret = StatusCode(StatusCodes.Status400BadRequest, "Invalid data passed to create new cash journal entry"); } } catch (Exception ex) { ret = HandleException(ex, "Exception trying to insert a new cash journal entry"); } return(ret); }
public IActionResult Put([FromBody] CashJournal entity) { IActionResult ret = null; try { if (entity != null) { using (var db = new BTAContext()) { db.Update(entity); db.SaveChanges(); ret = StatusCode(StatusCodes.Status200OK, entity); } } else { ret = StatusCode(StatusCodes.Status400BadRequest, "Invalid data passed for cash journal update"); } } catch (Exception ex) { ret = HandleException(ex, "Exception trying to update cash journal entry: " + entity.CashJournalId.ToString()); } return(ret); }
public IActionResult Get(int id) { IActionResult ret = null; CashJournal entity = null; try { using (var db = new BTAContext()) { entity = db.CashJournal.Find(id); if (entity != null) { ret = StatusCode(StatusCodes.Status200OK, entity); } else { ret = StatusCode(StatusCodes.Status404NotFound, "Can't Find Cash Journal Entry: " + id.ToString()); } } } catch (Exception ex) { ret = HandleException(ex, "Exception trying to retrieve a single cash journal entry."); } return(ret); }
public CashJournalEntry New(CashJournal journal) { return(new CashJournalEntry() { Id = 0, Date = DateTime.Now, Journal = journal }); }
private void SeedJournals(NtErpContext context) { CashJournal journal = new CashJournal() { Number = "SomeSequentialNumber", StartDate = DateTime.Now, EndDate = DateTime.Now.AddDays(30), Description = "Test Book" }; context.CashJournals.AddOrUpdate(j => j.Number, journal); }
public ActionResult CashJournal_GetTemplate() { using (FATContainer dataContainer = new FATContainer()) { JsonResult result = new JsonResult(); CashJournal cjInfo = dataContainer.CashJournal.Create(); cjInfo.TimeMark = DateTime.Now; result.Data = cjInfo; return(result); } }
public ActionResult CashJournal_Init() { using (FATContainer dataContainer = new FATContainer()) { CashJournal cjInfo = dataContainer.CashJournal.Create(); cjInfo.TchNodeID = Convert.ToInt32(RouteData.Values["id"]); TeachingNode tchNode = dataContainer.TeachingNode.FirstOrDefault(node => node.Row_ID == cjInfo.TchNodeID); cjInfo.TchRoutineID = tchNode.RoutineID; return(View(cjInfo)); } }
public ActionResult CashJournal_Insert(CashJournal info) { using (FATContainer dataContainer = new FATContainer()) { dataContainer.CashJournal.Add(info); dataContainer.SaveChanges(); JsonResult result = new JsonResult(); result.Data = info; return(result); } }
public ActionResult CashJournal_Update(CashJournal info) { using (FATContainer dataContainer = new FATContainer()) { CashJournal existedInfo = dataContainer.CashJournal.FirstOrDefault(item => item.Row_ID == info.Row_ID); dataContainer.Entry <CashJournal>(existedInfo).CurrentValues.SetValues(info); dataContainer.SaveChanges(); JsonResult result = new JsonResult(); result.Data = info; return(result); } }
public ActionResult CashJournal_Delete(int glRowID) { using (FATContainer dataContainer = new FATContainer()) { CashJournal cjInfo = dataContainer.CashJournal.FirstOrDefault(item => item.Row_ID == glRowID); dataContainer.CashJournal.Remove(cjInfo); dataContainer.SaveChanges(); JsonResult result = new JsonResult(); result.Data = string.Empty; return(result); } }
private void SeedJournalEntries(NtErpContext context) { CashJournal journal = context.CashJournals.Local.First(); CashJournalEntryPosition position = new CashJournalEntryPosition() { Delta = -200.0m, Description = "Devel Test", TaxRate = context.TaxRates.Local.First() }; CashJournalEntry entry = new CashJournalEntry() { Date = DateTime.Now, DocumentName = "ScanXY.pdf", ProcessDescription = "Some business process", //CashBalance = position.Delta, Journal = journal, Positions = new ObservableCollection <CashJournalEntryPosition>(new CashJournalEntryPosition[] { position }) }; context.CashJournalEntries.AddOrUpdate(e => e.ProcessDescription, entry); }
public ActionResult AppendCase(TeachingRoutine routine) { using (FATContainer dataContainer = new FATContainer()) { dataContainer.TeachingRoutine.Add(routine); dataContainer.SaveChanges(); var tempateNodeList = from node in dataContainer.TemplateNode where node.RoutineID == routine.TmpRoutineID orderby node.NodeIndex select node; List <TeachingNode> tchNodeList = new List <TeachingNode>(); foreach (TemplateNode tmpNode in tempateNodeList) { TeachingNode newNode = new TeachingNode() { CurrStatus = 0, RelTmpNode = tmpNode, RoutineID = routine.Row_ID, TmpNodeID = tmpNode.Row_ID }; tchNodeList.Add(newNode); dataContainer.TeachingNode.Add(newNode); } dataContainer.SaveChanges(); string currPhaseName = string.Empty; foreach (TeachingNode tchNode in tchNodeList) { switch (tchNode.NodeTag) { case "Guide": { currPhaseName = tchNode.NodeName; RoutineGroup group = dataContainer.RoutineGroup.Create(); group.GroupText = string.Empty; group.GroupIdx = tchNode.GroupIdx; group.TchRoutineID = routine.Row_ID; group.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; group.RoutineIntro = string.Empty; dataContainer.RoutineGroup.Add(group); break; } #region common node case "DetailedLedger": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { DetailedLedger info = dataContainer.DetailedLedger.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; dataContainer.DetailedLedger.Add(info); } break; } case "CashJournal": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { CashJournal info = dataContainer.CashJournal.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; dataContainer.CashJournal.Add(info); } break; } case "OuterSubject": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { OuterSubject info = dataContainer.OuterSubject.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; dataContainer.OuterSubject.Add(info); } break; } case "CustomerLedger": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { CustomerLedger info = dataContainer.CustomerLedger.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; info.BalanceTime = DateTime.Now; dataContainer.CustomerLedger.Add(info); } break; } case "GeneralLedger": { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { GeneralLedger info = dataContainer.GeneralLedger.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; info.TimeMark = DateTime.Now; dataContainer.GeneralLedger.Add(info); } break; } default: { if (tchNode.RelTmpNode.NodeType == "SpecialNode") { for (int i = 0; i <= tchNode.RelTmpNode.RequireRecord - 1; i++) { SubjectItem info = dataContainer.SubjectItem.Create(); info.TchNodeID = tchNode.Row_ID; info.TchRoutineID = routine.Row_ID; info.RoutineDesc = tchNode.GroupIdx + "." + currPhaseName; dataContainer.SubjectItem.Add(info); } } break; } #endregion #region special node #endregion } } dataContainer.SaveChanges(); } JsonResult result = new JsonResult(); result.Data = routine; return(result); }