예제 #1
0
        public async Task <IdentityResult> UpdateAsync(Role role, CancellationToken cancellationToken)
        {
            db.Entry(role).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            await db.SaveChangesAsync(cancellationToken);

            return(await Task.FromResult(IdentityResult.Success));
        }
예제 #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());
        }
예제 #3
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());
        }
예제 #4
0
        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());
        }
예제 #5
0
        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);
        }
예제 #6
0
        public async Task <IActionResult> Edit(string id, [Bind("Id,Name,Rate")] Product product)
        {
            if (id != product.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var oldProduct = await _context.Product.FindAsync(id);

                    _context.Entry(oldProduct).CurrentValues.SetValues(product);
                    await _context.SaveChangesAsync(User?.FindFirst(ClaimTypes.NameIdentifier)?.Value);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
예제 #7
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());
        }
예제 #8
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());
        }
예제 #9
0
 public ActionResult Edit(table1 table1)
 {
     if (ModelState.IsValid)
     {
         db.Entry(table1).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(table1));
 }
예제 #10
0
 public void Put(Categorias categoria)
 {
     _context.Entry(categoria).State = EntityState.Modified;
     _context.SaveChanges();
 }
예제 #11
0
 public void Put(Preguntas pregunta)
 {
     _context.Entry(pregunta).State = EntityState.Modified;
     _context.SaveChanges();
 }