public async Task <IActionResult> PutDepartmentModel(DepartmentModel departmentModel)
        {
            if (departmentModel.Id == 0)
            {
                setStatus("fail", "Error in request", 403);
                return(BadRequest(status));
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DepartmentModelExists(departmentModel.Id))
                {
                    setStatus("fail", "department not found", 401);
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            setStatus("success", "update department successfully", 200);
            return(Ok(status));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PutUserModel(UserModel user)
        {
            if (user.Id == 0)
            {
                setStatus("fail", "Error in request", 403);
                return(BadRequest(status));
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UserModelExists(user.Id))
                {
                    setStatus("fail", "user not found", 401);
                    return(NotFound(status));
                }
                else
                {
                    throw;
                }
            }
            setStatus("success", "update user successfully", 200);
            return(Ok(status));
        }
        public async Task <IActionResult> PutMessageChatModel(MessageChatModel message)
        {
            if (message.Id == 0)
            {
                setStatus("fail", "Error in request", 403);
                return(BadRequest(status));
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MessageChatModelExists(message.Id))
                {
                    setStatus("fail", "No message found", 404);
                    return(NotFound(status));
                }
                else
                {
                    throw;
                }
            }
            setStatus("success", "Update message sucessfully", 200);
            return(Ok(status));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> PutCompanyModel(CompanyModel companyModel)
        {
            if (companyModel.Id == 0)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }