コード例 #1
0
        /// <summary>
        /// Function to delete a ServiceEntity from database.
        /// </summary>
        /// <param name="serviceEntity">ServiceEntity to delete</param>
        /// <param name="session">User's session identifier.</param>
        /// <returns>null if the ServiceEntity was deleted successfully, the same ServiceEntity otherwise</returns>
        /// <exception cref="ArgumentNullException">
        /// if <paramref name="serviceEntity"/> is null.
        /// </exception>
        /// <exception cref="UtnEmallBusinessLogicException">
        /// If an UtnEmallDataAccessException occurs in DataModel.
        /// </exception>
        public ServiceEntity Delete(ServiceEntity serviceEntity, string session)
        {
            bool permited = ValidationService.Instance.ValidatePermission(session, "delete", "Service");

            if (!permited)
            {
                ExceptionDetail detail = new ExceptionDetail(new UtnEmall.Server.BusinessLogic.UtnEmallPermissionException("The user hasn't permissions to delete an entity"));
                throw new FaultException <ExceptionDetail>(detail);
            }

            if (serviceEntity == null)
            {
                throw new ArgumentException("The argument can not be null or be empty");
            }
            try
            {
                // Delete serviceEntity using data access object
                serviceDataAccess.Delete(serviceEntity);
                return(null);
            }
            catch (UtnEmallDataAccessException utnEmallDataAccessException)
            {
                throw new UtnEmall.Server.BusinessLogic.UtnEmallBusinessLogicException(utnEmallDataAccessException.Message, utnEmallDataAccessException);
            }
        }
コード例 #2
0
 public ActionResult DeleteConfirm(int id)
 {
     if (ServiceDataAccess.Delete(id))
     {
         return(Json(new { success = true, message = "Success" }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(new { success = false, message = "Success" }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new { success = false, message = "Error" }, JsonRequestBehavior.AllowGet));
 }
コード例 #3
0
 /// <summary>
 /// Función para eliminar un ServiceEntity de la base de datos.
 /// </summary>
 /// <param name="serviceEntity">ServiceEntity a eliminar</param>
 /// <param name="session">Identificador de sesión.</param>
 /// <returns>null si el ServiceEntity fue eliminado con éxito, el mismo ServiceEntity en otro caso</returns>
 /// <exception cref="ArgumentNullException">
 /// Si <paramref name="serviceEntity"/> is null.
 /// </exception>
 /// <exception cref="UtnEmallBusinessLogicException">
 /// Si una excepción UtnEmallDataAccessException ocurre en el data model.
 /// </exception>
 public ServiceEntity Delete(ServiceEntity serviceEntity)
 {
     if (serviceEntity == null)
     {
         throw new ArgumentException("The argument can't be null", "serviceEntity");
     }
     try
     {
         // Elimina un serviceEntity usando un objeto data access
         serviceDataAccess.Delete(serviceEntity);
         return(null);
     }
     catch (UtnEmallDataAccessException utnEmallDataAccessException)
     {
         throw new UtnEmallBusinessLogicException(utnEmallDataAccessException.Message, utnEmallDataAccessException);
     }
 }
コード例 #4
0
        public static void Delete(int serviceId)
        {
            var serviceInDatabase = GetAndCheckValid(serviceId);

            ServiceDataAccess.Delete(serviceInDatabase);
        }