Example #1
0
 public Response <AlbumDto> Create(AlbumDto newObject)
 {
     try
     {
         if (newObject != null && ValidateName(newObject) && ValidateReleased(newObject))
         {
             Response <int> dataResponse = dal.Insert(newObject);
             newObject.Id = dataResponse.Data;
             return(new Response <AlbumDto>(dataResponse.Status, dataResponse.Message, newObject));
         }
         return(new Response <AlbumDto>(false, "Object Null or Album Name or Year release aren't valid.", null));
     }
     catch (Exception e)
     {
         if (e.InnerException == null)
         {
             return(new Response <AlbumDto>(false, "Somethig was wrong. Exception: " + e.Message, null));
         }
         else
         {
             return(new Response <AlbumDto>(false, "Somethig was wrong. Exception: " + e.InnerException.InnerException.Message, null));
         }
     }
 }
        /// <summary>
        /// Add new Album
        /// </summary>
        /// <param name="album"></param>
        public static void Add(Album album)
        {
            IAlbum userResource = Resource.GetResource <IAlbum>();

            userResource.Insert(album);
        }