Beispiel #1
0
        public async Task <IActionResult> PutCategoriYars(short id, CategoriYars categoriYars)
        {
            if (id != categoriYars.IdCategori)
            {
                return(BadRequest());
            }

            _context.Entry(categoriYars).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CategoriYarsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #2
0
        public async Task <IActionResult> PutUserInfo(int id, UserInfo userInfo)
        {
            if (id != userInfo.IdUsers)
            {
                return(BadRequest());
            }

            _context.Entry(userInfo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserInfoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #3
0
        public async Task <IActionResult> PutHelthStatus(short id, HelthStatus helthStatus)
        {
            if (id != helthStatus.IdHealth)
            {
                return(BadRequest());
            }

            _context.Entry(helthStatus).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HelthStatusExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutParticipation(int id, Participation participation)
        {
            if (id != participation.IdParticipation)
            {
                return(BadRequest());
            }

            _context.Entry(participation).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ParticipationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #5
0
        public async Task <IActionResult> PutOfise(int id, Ofise ofise)
        {
            if (id != ofise.IdOfis)
            {
                return(BadRequest());
            }

            _context.Entry(ofise).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OfiseExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #6
0
        public async Task <IdentityResult> CreateAsync(Role role, CancellationToken cancellationToken)
        {
            db.Add(role);

            await db.SaveChangesAsync(cancellationToken);

            return(await Task.FromResult(IdentityResult.Success));
        }
        public async Task <IActionResult> Create([Bind("Id,LastName,FirstName,Age,City")] Persons persons)
        {
            if (ModelState.IsValid)
            {
                _context.Add(persons);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(persons));
        }
        public async Task <IActionResult> Create([Bind("EmpID,EmpLastName,EmpFirstName,EmpOrganization,EmpCity")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(employee));
        }
Beispiel #9
0
        public async Task <IActionResult> Create([Bind("Id,Name,Rate")] Product product)
        {
            if (ModelState.IsValid)
            {
                _context.Add(product);
                await _context.SaveChangesAsync(User?.FindFirst(ClaimTypes.NameIdentifier)?.Value);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
        public async Task <string> Authenticate(NetworkCredential credentials)
        {
            //Leer de la BD el usaurio que coincida con el username
            var usuario = await _context.DbUsuarios.FindAsync(credentials.UserName);

            if (usuario == null)
            {
                return("");
            }
            ;

            //Se valida usuario y clave
            if (usuario.Clave != credentials.Password)
            {
                return("");
            }
            ;

            //generar token
            string token = "";

            token         = System.Guid.NewGuid().ToString();
            usuario.Token = token;

            //escribir Token en la BD
            _context.Entry(usuario).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            //Retornar Token
            return(token);
        }
 /// <summary>
 /// 添加用户
 /// </summary>
 /// <param name="users"></param>
 /// <returns></returns>
 public async Task <int> AddAsync(Users users)
 {
     using (var db = new testContext())
     {
         db.Users.Add(users);
         return(await db.SaveChangesAsync());
     }
 }