Beispiel #1
0
        public async Task <IResult <Notes> > Create(Notes note)
        {
            if (note == null)
            {
                _logger.LogWarning("[NoteService] Create: Note is null");
                return(new Result <Notes>(null, Common.Enums.StatusCode.BAD_REQUEST));
            }

            var now = DateTimeOffset.UtcNow;

            note.User    = _user.Name;
            note.Created = now;
            note.Updated = now;
            note.Id      = 0;

            _wsContext.Notes.Add(note);

            try
            {
                await _wsContext.SaveChangesAsync();
            }
            catch (Exception)
            {
                _logger.LogError("[NoteService] Create: Error saving changes");
            }
            return(new Result <Notes>(note, Common.Enums.StatusCode.OK));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,UserName,NormalizedUserName,Email,NormalizedEmail,EmailConfirmed,PasswordHash,SecurityStamp,ConcurrencyStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEnd,LockoutEnabled,AccessFailedCount")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("Id,Canal,User,Notificar")] InscritosCanal inscritosCanal)
        {
            if (ModelState.IsValid)
            {
                _context.Add(inscritosCanal);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Canal"] = new SelectList(_context.Canal, "Id", "Id", inscritosCanal.Canal);
            ViewData["User"]  = new SelectList(_context.User, "Id", "Id", inscritosCanal.User);
            return(View(inscritosCanal));
        }