Ejemplo n.º 1
0
        public async Task <IActionResult> OnPostDeleteAsync(int ID)
        {
            var journal = await _db.Journals.FindAsync(ID);

            if (journal != null)
            {
                _db.Journals.Remove(journal);
                await _db.SaveChangesAsync();
            }

            return(RedirectToPage());
        }
Ejemplo n.º 2
0
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            JournalModel.CreatedAt = DateTime.Now;
            _context.JournalModel.Add(JournalModel);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            JournalModel = await _context.JournalModel.FindAsync(id);

            if (JournalModel != null)
            {
                _context.JournalModel.Remove(JournalModel);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <Guid> Save(Model.LogEntry log)
        {
            var result = Guid.Empty;

            var entity = new Entities.LogEntry()
            {
                Id          = log.Id,
                Timestamp   = log.Timestamp,
                Application = log.Application,
                Source      = log.Source,
                Level       = log.Level,
                Event       = log.Event,
                Message     = log.Message
            };

            entity.Properties = new List <Entities.LogProperty>();

            foreach (var i in log.Properties)
            {
                entity.Properties.Add(new Entities.LogProperty()
                {
                    Key   = i.Key,
                    Value = i.Value
                });
            }

            entity.Tags = new List <Entities.LogTag>();

            foreach (var i in log.Tags)
            {
                entity.Tags.Add(new Entities.LogTag()
                {
                    Value = i
                });
            }

            await db.Logs.AddAsync(entity);

            if (await db.SaveChangesAsync() > 0)
            {
                result = entity.Id;
            }

            return(result);
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> OnPostSaveAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Journal.DTCreation = DateTime.Now;
            _db.Journals.Add(Journal);

            try
            {
                await _db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                ModelState.AddModelError(string.Empty, "Unable to save. " +
                                         "The journal entity was changed by another user.");
                return(Page());
            }
            return(Redirect("/Journal/Index"));
        }