예제 #1
0
        public void Delete(int id)
        {
            #region Preconditions

            if (userTaskRepository == null)
            {
                throw new InvalidOperationException();
            }

            if (id <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            #endregion

            var userTask = userTaskRepository.GetItem(id);

            if (userTask == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            userTaskRepository.Remove(id);
        }
예제 #2
0
        public void Delete(int id)
        {
            #region Preconditions

            if (userTaskRepository == null)
            {
                throw new InvalidOperationException();
            }

            if (id <= 0)
            {
                throw new ArgumentOutOfRangeException();
            }

            #endregion

            try
            {
                var userTask = userTaskRepository.GetItem(id);

                if (userTask == null)
                {
                    logger.Error($"pi/Tasks/id Delete userTaskRepository Failed id: {id} ", users.First(u => u.UserName == User.Identity.Name).Id);
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }

                userTaskRepository.Remove(id);

                logger.Info($"Task Delete id: {id} Deleted by: { User.Identity.Name} ", users.First(u => u.UserName == User.Identity.Name).Id);
            }


            catch (Exception ex)
            {
                logger.Error($"api/Tasks/id Delete Id: {id}, Error: {ex.Message} ", users.First(u => u.UserName == User.Identity.Name).Id);
            }
        }