public async Task <IActionResult> DeleteOrganizationType(int id)
        {
            var organizationType = await _repo.GetOrganizationTypeById(id);

            _repo.Delete(organizationType);
            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest("Could not delete Organzation type"));
        }
示例#2
0
 public async Task <ActionResult <string> > DeleteDelivery(int DeliveryID = 0)
 {
     if (DeliveryID > 0)
     {
         var del = deliveryRepository.GetByID(DeliveryID);
         if (del != null)
         {
             generalRepository.Delete <Delivery>(del);
             if (await generalRepository.SaveChangesAsync())
             {
                 return(Ok("Dostava pod brojem " + DeliveryID + " je obrisana"));
             }
             else
             {
                 return(NotFound("Brisanje dostave pod brojem  " + DeliveryID + " nije uspelo."));
             }
         }
         else
         {
             return(NotFound("Dostava pod brojem  " + DeliveryID + " nije pronađena."));
         }
     }
     else
     {
         return(NotFound("Dostava pod brojem  " + DeliveryID + " nije pronađena."));
     }
 }
示例#3
0
        public ActionResult Delete(Member member)
        {
            var aResult = new ActionResult();

            try
            {
                if (!_repository.Delete(member))
                {
                    aResult.Exceptions.Add(new Exception("Deleted process had been failed!"));
                }
            }
            catch (Exception ex)
            {
                aResult.Exceptions.Add(ex);
            }
            return(aResult);
        }
示例#4
0
        public ActionResult Delete(Category category)
        {
            var aResult = new ActionResult();

            try
            {
                if (!_repository.Delete(category))
                {
                    aResult.Exceptions.Add(new Exception("Deleted process had been fail!"));
                }
            }
            catch (Exception ex)
            {
                aResult.Exceptions.Add(ex);
            }
            return(aResult);
        }
        public ActionResult Delete(WageCoefficient wageCoeff)
        {
            var aResult = new ActionResult();

            try
            {
                if (!_repository.Delete(wageCoeff))
                {
                    aResult.Exceptions.Add(new Exception("Deleting had been fail!"));
                }
            }
            catch (Exception ex)
            {
                aResult.Exceptions.Add(ex);
            }
            return(aResult);
        }
示例#6
0
        /// <summary>
        /// Deletes the order.
        /// </summary>
        /// <param name="orderId">The order identifier.</param>
        /// <exception cref="System.ArgumentOutOfRangeException">orderId</exception>
        public void DeleteOrder(int orderId)
        {
            if (orderId < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(orderId));
            }
            var order = _orderRepo.Find(orderId);

            _orderRepo.Delete(order);
        }
示例#7
0
        public async Task <IActionResult> Delete(int id)
        {
            var studentFromDb = await _repo.GetStudentByIdAsync(id);

            _repo.Delete(studentFromDb);
            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(StatusCode(500, new { status = "error", message = "Error Occured please try again later, please try again later..." }));
        }
示例#8
0
        public ActionResult Delete(int moduleId)
        {
            General deleted = repository.Delete(moduleId);

            if (deleted != null)
            {
                TempData["message"] = string.Format("Запись \"{0}\" была удалена",
                                                    deleted.Name);
            }
            return(RedirectToAction("Index"));
        }
示例#9
0
 public ActionResult <bool> DeleteUserRole(int id)
 {
     try
     {
         UserRole ur = userRoleRepository.GetUserRoleByID(id);
         generalRepository.Delete <UserRole>(ur);
         return(Ok(true));
     }
     catch (Exception ex)
     {
         return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
     }
 }
示例#10
0
        public async Task <IActionResult> DeletePhoto(int id)
        {
            var userId       = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value);
            var userFromRepo = await _repo.GetUser(userId);

            if (!userFromRepo.Photos.Any(p => p.Id == id))
            {
                return(Unauthorized());
            }
            var photoFromRepo = await _repo.GetPhoto(id);

            if (photoFromRepo.IsMain)
            {
                return(BadRequest("you cannot delete the main photo"));
            }
            // optionally to remove seed images
            if (photoFromRepo.PublicID != null)
            {
                var deleteParamas = new DeletionParams(photoFromRepo.PublicID);
                var result        = _cloudinary.Destroy(deleteParamas);
                if (result.Result == "ok")
                {
                    _repo.Delete(photoFromRepo);
                }
            }
            if (photoFromRepo.PublicID == null)
            {
                _repo.Delete(photoFromRepo);
            }

            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest("could not delete photo"));
        }
示例#11
0
        public ActionResult Delete(int orderID)
        {
            var aResult = new ActionResult();

            try
            {
                if (!_repository.Delete(de => de.OrderID == orderID))
                {
                    aResult.Exceptions.Add(new Exception(String.Format("Delete all order details of order, whitch id {0} had been fails!", orderID)));
                }
            }
            catch (Exception ex)
            {
                aResult.Exceptions.Add(ex);
            }
            return(aResult);
        }
示例#12
0
        public ActionResult Delete(int stockReceivedID)
        {
            var aResult = new ActionResult();

            try
            {
                if (!_repository.Delete(de => de.StockRecievedID == stockReceivedID))
                {
                    aResult.Exceptions.Add(new Exception(String.Format("Delete all stock received details of stock received, whitch id {0} had been fails!", stockReceivedID)));
                }
            }
            catch (Exception ex)
            {
                aResult.Exceptions.Add(ex);
            }
            return(aResult);
        }
示例#13
0
        public async Task <IActionResult> deleteUser(int userId)
        {
            var usersFromRepo = await _repo.GetUser(userId);

            var voterParams = new VoterParams();
            var Voters      = await _repo.GetReferenceVoters(userId, voterParams);

            foreach (Voter element in Voters)
            {
                element.ReferenceId = null;
            }
            _repo.Delete(usersFromRepo);
            if (await _repo.SaveAll())
            {
                return(NoContent());
            }
            return(BadRequest($"Failed To Delete User"));
        }
示例#14
0
 public void Delete(long id)
 {
     _userRoleRepo.Delete($"UserId={id}");
     _userRepo.Delete(id);
 }
 public void Delete <T>(T entity) where T : class, TEntity
 {
     _general.Delete(entity);
 }
示例#16
0
 public TModel Delete <TModel>(TModel obj) where TModel : BaseModel
 {
     return(_repository.Delete(obj));
 }