Exemplo n.º 1
0
        public ApiResult Delete(int id)
        {
            ApiResult result = new ApiResult();

            try
            {
                if (_userData.Delete(id))
                {
                    result.IsError = false;
                    result.Message = "Usuario eliminado con exito";
                }
                else
                {
                    result.CodeMsg = 1;
                    result.IsError = true;
                    result.Message = "No se pudo eliminar el usuario";
                }
            }
            catch (Exception ex)
            {
                result.CodeMsg = 2;
                result.IsError = true;
                result.Message = ex.Message;
            }
            return(result);
        }
Exemplo n.º 2
0
        public async Task <bool> DeleteUser(int id)
        {
            return(await Task.Run <bool>(async() =>
            {
                try
                {
                    var rightsID = await _userRights.Get(id);
                    await _userRights.Delete(rightsID.Id);

                    var fingerPrintsIDs = await _fingerPrintData.Get(id);
                    foreach (var fingerprint in fingerPrintsIDs)
                    {
                        await _fingerPrintData.Delete(fingerprint.Id);
                    }

                    await _userData.Delete(id);

                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }));
        }
        public IActionResult OnPost(string username)
        {
            var confirmdelete = deleteUser.Delete(username);

            deleteUser.Commit();
            return(RedirectToPage("./UsersList"));
        }
Exemplo n.º 4
0
        public IActionResult OnPost(int userID)
        {
            var user = _userData.Delete(userID);

            _userData.Save();

            return(RedirectToPage("./List"));
        }
Exemplo n.º 5
0
        public ActionResult UserDelete(int id, int?cos)  //gdziesz widziałem jak to zrobić inaczej ROZWIAZANE W SHOPMANAGER KONTROLER ZOSTAWIAM JAKO PRZYKŁAD
        {
            var model = database.Get(id);

            database.Delete(model);
            TempData["Message"] = "Student usuniety z bazy danych";
            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
 public ActionResult Delete(string username, FormCollection frm)
 {
     if (ModelState.IsValid)
     {
         db.Delete(username);
         return(RedirectToAction("List"));
     }
     return(View());
 }
Exemplo n.º 7
0
 public IActionResult OnPost(string userId)
 {
     DeletedUser = userData.Delete(userId);
     userData.Commit();
     if (DeletedUser == null)
     {
         return(RedirectToPage("../NotFound"));
     }
     return(RedirectToPage("../UsersList"));
 }
Exemplo n.º 8
0
        public IActionResult Delete(int id)
        {
            if (_userData.GetById(id) == null)
            {
                return(NotFound());
            }

            _userData.Delete(id);

            return(Ok());
        }
Exemplo n.º 9
0
        public void Execute(DeleteUserCommnadRequest deleteUserCommnad)
        {
            User user = _userdata.GetUser(deleteUserCommnad.Id);

            if (user is null)
            {
                throw new ResponseException(HttpStatusCode.BadRequest, $"The user id does not exist");
            }

            _userdata.Delete(deleteUserCommnad.Id);
        }
Exemplo n.º 10
0
        public IActionResult Delete(int id)
        {
            if (id == 0)
            {
                return(BadRequest());
            }
            User user = _userData.GetById(id);

            if (user == null)
            {
                return(NotFound());
            }
            IEnumerable <Video>   userVideos   = _videoData.GetByOwnerId(user.Id);
            IEnumerable <Comment> userComments = _commentData.GetCommentsByUser(user.Id);

            foreach (var v in userVideos)
            {
                _videoData.Delete(v);
            }
            foreach (var c in userComments)
            {
                _commentData.Delete(c);
            }
            _userData.Delete(user);
            int loggedInUserId = int.Parse(HttpContext.Session.GetString("LoggedInUserId"));

            if (loggedInUserId == id)
            {
                HttpContext.Session.Remove("LoggedInUserId");
                HttpContext.Session.Remove("LoggedInUserRole");
                HttpContext.Session.Remove("LoggedInUserUsername");
            }
            var contentType = Request.ContentType;

            if (contentType != null)
            {
                if (contentType.Equals("application/json"))
                {
                    return(NoContent());
                }
                else if (contentType.Equals("text/html"))
                {
                    return(RedirectToAction(nameof(GetById), id));
                }
                else if (contentType.Equals("application/x-www-form-urlencoded"))
                {
                    return(RedirectToAction(nameof(GetById), id));
                }
                return(StatusCode(415));
            }
            return(Json("Success"));
        }
Exemplo n.º 11
0
 public void OnPost()
 {
     dbUserData.Delete(UserId);
     deleteCode = dbUserData.Commit();
     if (deleteCode == 1)
     {
         RedirectToPage("Users");
     }
     else
     {
         DeleteSuccess = false;
     }
 }
        public IActionResult OnPost(int userId)
        {
            var user = _data.Delete(userId);

            _data.Commit();
            if (user == null)
            {
                return(RedirectToPage("./NotFound"));
            }

            TempData["Message"] = $"{user.FirstName} {user.LastName} deleted";
            return(RedirectToPage("./List"));
        }
Exemplo n.º 13
0
        public ActionResult UserDelete(User user)
        {
            int identy = Convert.ToInt32(Session["UserId"]);
            var model  = database.Get(identy);

            if (model.UserPassword == user.UserPassword)
            {
                database.Delete(model);
                TempData["Usunieto"] = "Konto usunięte";
                Session.Clear();
                return(RedirectToAction("Index", "Home", new { area = "" }));
            }
            TempData["BadPass"] = "******";
            return(RedirectToAction("UserDelete"));
        }
        public async Task <IHttpActionResult> Delete(string principalName)
        {
            try
            {
                var user = db.Get(principalName);
                if (user == null)
                {
                    return(NotFound());
                }
                db.Delete(user);
                if (!await db.SaveChangesAsync())
                {
                    return(InternalServerError());
                }
                return(Ok());
            }
            catch (Exception)
            {
                return(InternalServerError());

                throw;
            }
        }
Exemplo n.º 15
0
 public void Delete(int id)
 {
     _userData.Delete(id);
 }
Exemplo n.º 16
0
 public async Task <ResponseResult> Delete(long id) => await data.Delete(id);
Exemplo n.º 17
0
 public Boolean DeleteUser(int id)
 {
     return(source.Delete(id));
 }