/// <summary> /// This method sets IsDeleted column to true value /// for the particular image to be deleted /// </summary> /// <param name="userID">userID</param> /// <param name="imgID">imgID</param> /// <returns></returns> public bool DeleteMarketingImage(int userID, int imgID) { try { using (var unitOfWork = new EFUnitOfWork()) { var userImageRepo = new UserImageRepository(new EFRepository <UserImage>(), unitOfWork); ObjectSet <UserImage> userImgObjSet = ((CurrentDeskClientsEntities)userImageRepo.Repository.UnitOfWork.Context).UserImages; var deletedImg = userImgObjSet.Where(usr => usr.FK_UserID == userID && usr.PK_UserImageID == imgID).FirstOrDefault(); if (deletedImg != null) { deletedImg.IsDeleted = true; userImageRepo.Save(); return(true); } return(false); } } catch (Exception ex) { CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); return(false); } }
// Add your own data access methods here. If you wish to // expose your public method to a WCF service, marked them with // the attribute [NCPublish], and another T4 template will generate your service contract /// <summary> /// This method stores uploaded image details in database /// </summary> /// <param name="imgName">imgName</param> /// <param name="userID">userID</param> /// <returns></returns> public int AddMarketingImageDetails(string imgName, int userID) { try { using (var unitOfWork = new EFUnitOfWork()) { var userImageRepo = new UserImageRepository(new EFRepository <UserImage>(), unitOfWork); UserImage image = new UserImage(); image.ImageName = imgName; image.FK_UserID = userID; image.Status = "Pending"; image.IsDeleted = false; userImageRepo.Add(image); userImageRepo.Save(); return(image.PK_UserImageID); } } catch (Exception ex) { CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); throw; } }
/// <summary> /// This method returns list of image details of user /// </summary> /// <param name="userID">userID</param> /// <returns></returns> public List <UserImage> GetAllMarketingImagesOfUser(int userID) { try { using (var unitOfWork = new EFUnitOfWork()) { var userImageRepo = new UserImageRepository(new EFRepository <UserImage>(), unitOfWork); ObjectSet <UserImage> userImgObjSet = ((CurrentDeskClientsEntities)userImageRepo.Repository.UnitOfWork.Context).UserImages; return(userImgObjSet.Where(usr => usr.FK_UserID == userID && usr.IsDeleted == false).ToList()); } } catch (Exception ex) { CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); throw; } }
/// <summary> /// This method returns active image details of an IB /// </summary> /// <param name="userID">userID</param> /// <returns></returns> public UserImage GetActiveImageOfIB(int userID) { try { using (var unitOfWork = new EFUnitOfWork()) { var userImageRepo = new UserImageRepository(new EFRepository <UserImage>(), unitOfWork); ObjectSet <UserImage> userImgObjSet = ((CurrentDeskClientsEntities)userImageRepo.Repository.UnitOfWork.Context).UserImages; return(userImgObjSet.Where(img => img.FK_UserID == userID && img.Status == "Active" && img.IsDeleted == false).FirstOrDefault()); } } catch (Exception ex) { CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); throw; } }