Example #1
0
        public async Task <IActionResult> GetGeneralJournal(int id, CancellationToken cancellationToken)
        {
            var generalJournal = await _generalJournalRepository.GetGeneralJournalAsync(id, cancellationToken);

            if (generalJournal == null)
            {
                return(this.NotFound());
            }
            return(this.Ok(generalJournal));
        }
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public async Task<IActionResult> Create(GeneralJournal generalJournal)
        //{
        //    var taskCode = await Task.FromResult(0);

        //    if (ModelState.IsValid)
        //    {
        //        await _generalJournalRepository.AddOrUpdateGeneralJournalAsync(generalJournal);
        //        TempData.Clear();
        //        return RedirectToAction(nameof(Index));
        //    }
        //    return View(generalJournal);
        //}

        // GET: Journals/Edit/5
        public async Task <IActionResult> Edit(int id)
        {
            //if (id == null)
            //{
            //    return NotFound();
            //}

            var taskCode = await Task.FromResult(0);

            object         tempJournal    = null;
            GeneralJournal generalJournal = null;

            if (TempData.TryGetValue("GeneralJournal", out tempJournal) == true)
            {
                generalJournal = JsonConvert.DeserializeObject <GeneralJournal>((string)tempJournal);

                if (generalJournal.Id.Equals(id) == false)
                {
                    generalJournal = await _generalJournalRepository.GetGeneralJournalAsync(id);
                }
            }
            else
            {
                generalJournal = await _generalJournalRepository.GetGeneralJournalAsync(id);
            }

            if (generalJournal == null)
            {
                return(NotFound());
            }

            var serializeObject = JsonConvert.SerializeObject(generalJournal);

            TempData["GeneralJournal"] = serializeObject;

            return(View(generalJournal));
        }