コード例 #1
0
        public async Task<ResponseViewModel> DeleteUser(UserDto model)
        {
            ResponseViewModel response = new ResponseViewModel();
            try
            {
                var user = _mapper.Map<User>(model);
                var filter = Builders<User>.Filter.Eq(x => x.Id, user.Id);
                Expression<Func<User, bool>> whereCondition = x => ((!string.IsNullOrEmpty(user.Id) && x.Id == user.Id));
                var resp = _userRepository.GetById(whereCondition).FirstOrDefault();
                resp.IsDeleted = true;
                var result = await _userRepository.Delete(filter, resp);
                if (result != null)
                {
                    model.IsDeleted = true;
                    response.Message = Constants.Delete;
                    response.ResponseData = model;
                    response.Status = (int)Numbers.One;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return response;

        }
コード例 #2
0
        public async Task <bool> DeleteTodo(string id)
        {
            var todo = await GetTodoById(id);

            if (todo != null)
            {
                _todoRepository.Delete(todo);
                return(true);
            }
            return(false);
        }
コード例 #3
0
        public IActionResult DeleteStudent(string id)
        {
            _studentRepository.Delete(id);

            return(RedirectToAction("Index"));
        }