Exemple #1
0
        public async Task <IActionResult> PutDaliyLog(DaliyLog daliyLog)
        {
            //if (id != daliyLog.Id)
            //{
            //    return BadRequest();
            //}
            if (daliyLog.Id != null && DaliyLogExists(daliyLog.Id))
            {
                _context.Entry(daliyLog).State = EntityState.Modified;
            }
            else
            {
                return(NotFound());
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DaliyLogExists(daliyLog.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <bool> EditUserAsync(UserDto user)
        {
            try
            {
                var editedUser = _context.Entry(_mapper.Map <UserEntity>(user)).State = EntityState.Modified;
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public async Task <IActionResult> PutUser(int id, User user)
        {
            if (id != user.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
 public ActionResult Edit([Bind(Include = "id,name,password,age,updatedDateTime")] Users users)
 {
     if (ModelState.IsValid)
     {
         db.Entry(users).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(users));
 }