/// <summary>
 /// Method ToDalCategoryPhoto convert CategoryPhotoEntity to DalCategoryPhoto.
 /// </summary>
 /// <param name="ctgrPhoto">CategoryPhotoEntity that need convert.</param>
 /// <returns>DalCategoryPhoto entity.</returns>
 public static DalCategoryPhoto ToDalCategoryPhoto(this CategoryPhotoEntity ctgrPhoto)
 {
     return(new DalCategoryPhoto()
     {
         Id = ctgrPhoto.CategoryId,
         Name = ctgrPhoto.Name
     });
 }
Exemple #2
0
 public static CategoryPhotoViewModel ToMvcCtgrPhoto(this CategoryPhotoEntity ctgrPhotoEntity)
 {
     return(new CategoryPhotoViewModel()
     {
         Id = ctgrPhotoEntity.CategoryId,
         Name = ctgrPhotoEntity.Name
     });
 }
Exemple #3
0
 /// <summary>
 /// Method DeleteCategoryPhoto use for delete category photo.
 /// </summary>
 /// <param name="ctgrPhoto">CategoryPhotoEntity that need delete.</param>
 public void DeleteCategoryPhoto(CategoryPhotoEntity ctgrPhoto)
 {
     try {
         ctgrPhotoRepository.Delete(ctgrPhoto.ToDalCategoryPhoto());
         uow.Commit();
     }
     catch (Exception ex) {
         logger.Error(logger.GetMessage("Delete category photo was failed.", this), ex);
     }
 }
        /// <summary>
        /// Method return photo by category.
        /// </summary>
        /// <param name="categoryPhoto">Category of photos.</param>
        /// <returns>Photos by categoryPhoto.</returns>
        public IEnumerable <PhotoEntity> GetPhotoByCategory(string categoryPhoto)
        {
            try {
                CategoryPhotoEntity category = categoryRepository.GetByName(categoryPhoto).ToBllCategoryPhoto();
                return(photoRepository.GetAll().Where(photo => photo.CategoryId == category.CategoryId).Select(photo => photo.ToBllPhoto()));
            }
            catch (Exception ex) {
                logger.Error(logger.GetMessage("Get photo by category was failed.", this), ex);
            }

            return(null);
        }