Example #1
0
        public async Task <ActionResult> UpdateStatusAndRole([FromForm] RoleAndStatus roleAndStatus)
        {
            bool isUpdate = await _userServices.UpdateRoleAndStatus(roleAndStatus);

            if (isUpdate)
            {
                return(Ok(new { data = "Cap nhat thanh cong", success = true }));
            }
            else
            {
                return(Ok(new { error_message = "Co loi xay ra" }));
            }
        }
Example #2
0
        internal async Task <bool> UpdateRoleAndStatus(RoleAndStatus roleAndStatus)
        {
            User user = _bookstoreContext.Users.Find(roleAndStatus.Id);

            if (user is null)
            {
                return(false);
            }
            if (roleAndStatus.IsAccess is not null)
            {
                user.IsAccess = roleAndStatus.IsAccess ?? false;
            }
            if (roleAndStatus.RoleId is not null)
            {
                user.RoleId = roleAndStatus.RoleId ?? 3;
            }

            return(await _bookstoreContext.SaveChangesAsync() != 0);
        }