/// <summary> /// Function to check old password is correct or not /// </summary> /// <param></param> /// <returns>bool</returns> /// <devdoc> /// Developer Name - Arvind Kumar /// Date - 07/24/2015 /// </devdoc> private static bool IsOldPasswordCorrect(string oldPwd, int credId) { StringBuilder traceLog = null; bool flag = false; EncryptDecrypt objEncrypt = null; using (LinksMediaContext _dbContext = new LinksMediaContext()) { tblCredentials objCredential = null; try { traceLog = new StringBuilder(); traceLog.AppendLine("Start: IsOldPasswordCorrect"); objEncrypt = new EncryptDecrypt(); string encPwd = objEncrypt.EncryptString(oldPwd); objCredential = _dbContext.Credentials.Where(crd => crd.Id == credId && crd.Password == encPwd).FirstOrDefault(); if (objCredential != null) { flag = true; } return(flag); } finally { objEncrypt.Dispose(); traceLog.AppendLine("End: IsOldPasswordCorrect --- " + DateTime.Now.ToLongDateString()); LogManager.LogManagerInstance.WriteTraceLog(traceLog); objCredential = null; } } }
public static void UpdateLastLogin() { StringBuilder traceLog = new StringBuilder(); using (LinksMediaContext _dbContext = new LinksMediaContext()) { try { traceLog.AppendLine("Start: UpdateLastLogin"); if (System.Web.HttpContext.Current.Session != null) { int credentialId = Convert.ToInt32(System.Web.HttpContext.Current.Session["CredentialId"]); tblCredentials credential = _dbContext.Credentials.Where(m => m.Id == credentialId).FirstOrDefault(); credential.LastLogin = DateTime.Now; _dbContext.SaveChanges(); } } catch { throw; } finally { traceLog.AppendLine("UpdateLastLogin end() : --- " + DateTime.Now.ToLongDateString()); LogManager.LogManagerInstance.WriteTraceLog(traceLog); } } }
/// <summary> /// Function to change password /// </summary> /// <param></param> /// <returns>bool</returns> /// <devdoc> /// Developer Name - Arvind Kumar /// Date - 07/24/2015 /// </devdoc> public static bool ChangePassword(EditPasswordVM model) { StringBuilder traceLog = null; using (LinksMediaContext _dbContext = new LinksMediaContext()) { EncryptDecrypt objEncrypt = null; Credentials cred = null; try { traceLog = new StringBuilder(); traceLog.AppendLine("Start: ChangePassword"); bool flag = false; cred = CommonWebApiBL.GetUserId(Thread.CurrentPrincipal.Identity.Name); if (cred != null) { if (IsOldPasswordCorrect(model.OldPassword, cred.Id)) { objEncrypt = new EncryptDecrypt(); tblCredentials objCredential = _dbContext.Credentials.Where(crd => crd.Id == cred.Id).FirstOrDefault(); model.NewPassword = objEncrypt.EncryptString(model.NewPassword); if (objCredential != null) { objCredential.Password = model.NewPassword; } _dbContext.SaveChanges(); flag = true; } } return(flag); } finally { if (objEncrypt != null) { objEncrypt.Dispose(); objEncrypt = null; } traceLog.AppendLine("End: ChangePassword --- " + DateTime.Now.ToLongDateString()); LogManager.LogManagerInstance.WriteTraceLog(traceLog); } } }
public static bool UpdatePassword(ChangePassword model) { bool success = false; StringBuilder traceLog = new StringBuilder(); EncryptDecrypt objEncrypt = null; using (LinksMediaContext _dbContext = new LinksMediaContext()) { try { objEncrypt = new EncryptDecrypt(); traceLog.AppendLine("Start: Login, ValidateUser Method with Param UserName: "******"CredentialId"]); string password = objEncrypt.EncryptString(AntiXssEncoder.HtmlEncode(model.OldPassword.Trim(), false)); string newpassword = objEncrypt.EncryptString(AntiXssEncoder.HtmlEncode(model.NewPassword.Trim(), false)); tblCredentials credential = _dbContext.Credentials.FirstOrDefault(m => m.Id == credentialId && m.Password == password); if (credential == null) { return(success); } else { credential.Password = newpassword; _dbContext.Entry(credential).State = EntityState.Modified; _dbContext.SaveChanges(); success = true; } } catch { throw; } finally { objEncrypt.Dispose(); traceLog.AppendLine("Index Start end() : --- " + DateTime.Now.ToLongDateString()); LogManager.LogManagerInstance.WriteTraceLog(traceLog); } } return(success); }
/// <summary> /// Function to get activity by id /// </summary> /// <returns>ActivityVM</returns> /// <devdoc> /// Developer Name - Raghuraj Singh /// Date - 04/03/2015 /// </devdoc> public static ActivityVM GetActivityById(int id) { StringBuilder traceLog = null; using (LinksMediaContext dataContext = new LinksMediaContext()) { traceLog = new StringBuilder(); try { ///Get challenge detail by challenge traceLog.AppendLine("Start: GetActivityById for retrieving activity by id:" + id); tblActivity activity = dataContext.Activity.Find(id); Mapper.CreateMap <tblActivity, ActivityVM>(); ActivityVM objActivity = Mapper.Map <tblActivity, ActivityVM>(activity); tblFeaturedActivityQueue featuredActivityQueue = dataContext.FeaturedActivityQueue.Where(ce => ce.ActivityId == id).FirstOrDefault(); if (featuredActivityQueue != null) { objActivity.StartDate = featuredActivityQueue.StartDate; objActivity.EndDate = featuredActivityQueue.EndDate; } tblCredentials objCred = dataContext.Credentials.FirstOrDefault(c => c.Id == objActivity.TrainerId && c.UserType == Message.UserTypeTrainer); if (objCred != null) { objActivity.TrainerId = objCred.UserId; } return(objActivity); } catch { throw; } finally { traceLog.AppendLine("GetActivityById end() : --- " + DateTime.Now.ToLongDateString()); LogManager.LogManagerInstance.WriteTraceLog(traceLog); } } }
/// <summary> /// Function to submit activity into database /// </summary> /// <returns>void</returns> /// <devdoc> /// Developer Name - Raghuraj Singh /// Date - 04/01/2015 /// </devdoc> public static void SubmitActivity(ActivityVM objActivityVM) { StringBuilder traceLog = null; using (LinksMediaContext dataContext = new LinksMediaContext()) { using (System.Data.Entity.DbContextTransaction tran = dataContext.Database.BeginTransaction()) { traceLog = new StringBuilder(); try { traceLog.AppendLine("Start: SubmitActivity for creating activity"); tblCredentials objCred = dataContext.Credentials.FirstOrDefault(c => c.UserId == objActivityVM.TrainerId && c.UserType == Message.UserTypeTrainer); int trainerCredId = objCred.Id; objActivityVM.TrainerId = trainerCredId; Mapper.CreateMap <ActivityVM, tblActivity>(); tblActivity objActivity = Mapper.Map <ActivityVM, tblActivity>(objActivityVM); objActivity.CreatedDate = DateTime.Now; objActivity.ModifiedDate = objActivity.CreatedDate; // Add activity in to database dataContext.Activity.Add(objActivity); dataContext.SaveChanges(); tran.Commit(); } catch { tran.Rollback(); throw; } finally { traceLog.AppendLine("SubmitActivity end() : --- " + DateTime.Now.ToLongDateString()); LogManager.LogManagerInstance.WriteTraceLog(traceLog); } } } }
/// <summary> /// Function to authenticate User base on user credetials and get authencation token /// </summary> /// <param name="username">username</param> /// <param name="password">password</param> /// <returns>True/False</returns> public static bool ValidateUser(Credentials usercred, ref Credentials credential, ref string token, ref string userType, ref int userId) { bool success = false; StringBuilder traceLog = null; EncryptDecrypt objEncrypt = null; using (LinksMediaContext _dbContext = new LinksMediaContext()) { tblUserToken objTokenInfo = null; tblCredentials item = null; try { traceLog = new StringBuilder(); traceLog.AppendLine("Start: Login, ValidateUser Method with Param UserName: "******"Start to create user token"); success = true; credential.UserId = item.UserId; credential.UserType = item.UserType; //Code for Last Login of User item.LastLogin = DateTime.Now; /*delete old user token on same devices except current user*/ if (usercred != null && string.IsNullOrEmpty(usercred.DeviceID)) { DeleteOtherUserTokensOnDevices(usercred.DeviceID, usercred.DeviceType); } objTokenInfo = new tblUserToken(); objTokenInfo.UserId = item.Id; objTokenInfo.Token = CommonUtility.GetToken(); objTokenInfo.ClientIPAddress = ConstantKey.DeviceID; objTokenInfo.TokenDevicesID = string.IsNullOrEmpty(usercred.DeviceID) ? string.Empty : usercred.DeviceID; objTokenInfo.DeviceType = string.IsNullOrEmpty(usercred.DeviceType) ? string.Empty : usercred.DeviceType; objTokenInfo.IsExpired = false; objTokenInfo.ExpiredOn = DateTime.Now.AddMinutes(Convert.ToDouble(ConfigurationManager.AppSettings["ExpireDuration"])); objTokenInfo.IsRememberMe = usercred.RememberMe; objTokenInfo.DeviceUID = usercred.DeviceUID; _dbContext.UserToken.Add(objTokenInfo); _dbContext.SaveChanges(); if (string.IsNullOrEmpty(usercred.DeviceID)) { NotificationApiBL.ResetUserNotification(item.Id); } token = objTokenInfo.Token; userType = item.UserType; userId = item.UserId; traceLog.AppendLine("Token are created" + token); } return(success); } finally { objEncrypt.Dispose(); traceLog.AppendLine("Login Start end() : --- " + DateTime.Now.ToLongDateString() + success.ToString()); LogManager.LogManagerInstance.WriteTraceLog(traceLog); item = null; traceLog = null; objTokenInfo = null; } } }
/// <summary> /// Function to get challenge details of sponsor challenge /// </summary> /// <returns>SponsorChallengeDetailVM</returns> /// <devdoc> /// Developer Name - Arvind Kumar /// Date - 03/31/2015 /// </devdoc> public static SponsorChallengeDetailVM GetSponsorChallengeDetails(int challengeId) { StringBuilder traceLog = null; using (LinksMediaContext _dbContext = new LinksMediaContext()) { try { traceLog = new StringBuilder(); traceLog.AppendLine("Start: GetSponsorChallengeDetails---- " + DateTime.Now.ToLongDateString()); SponsorChallengeDetailVM objChallengedetail = (from c in _dbContext.Challenge join cred in _dbContext.Credentials on c.CreatedBy equals cred.Id join ct in _dbContext.ChallengeType on c.ChallengeSubTypeId equals ct.ChallengeSubTypeId join tc in _dbContext.TrainerChallenge on c.ChallengeId equals tc.ChallengeId join uc in _dbContext.UserChallenge on tc.ResultId equals uc.Id join h in _dbContext.HypeVideos on tc.HypeVideoId equals h.RecordId where c.ChallengeId == challengeId && c.IsActive == true select new SponsorChallengeDetailVM { ChallengeId = c.ChallengeId, ChallengeName = c.ChallengeName, DifficultyLevel = c.DifficultyLevel, ChallengeType = ct.ChallengeType, Strenght = _dbContext.UserChallenge.Where(uchlng => uchlng.ChallengeId == c.ChallengeId).Select(y => y.UserId).Distinct().Count(), ResultUnit = ct.ResultUnit, ResultUnitSuffix = uc.ResultUnit, ChallengeDescription = ct.ChallengeSubType, Excercises = (from exer in _dbContext.Exercise join ce in _dbContext.CEAssociation on exer.ExerciseId equals ce.ExerciseId where ce.ChallengeId == c.ChallengeId select new ExerciseVM { ExerciseId = exer.ExerciseId, ExerciseName = exer.ExerciseName, ExcersiceDescription = exer.Description, ChallengeExcerciseDescription = ce.Description, VedioLink = exer.VideoLink, Index = exer.Index, Reps = ce.Reps, WeightForManDB = ce.WeightForMan, WeightForWomanDB = ce.WeightForWoman, }).ToList(), HypeVideo = h.HypeVideo, Result = (uc.Result == null ? "" : uc.Result) + " " + (uc.Fraction == null ? "" : uc.Fraction), VariableValue = c.VariableValue, ChallengeSubTypeId = ct.ChallengeSubTypeId, VariableUnit = ct.Unit, CreatedByUserType = cred.UserType, CreatedByTrainerId = cred.UserId, PersonalBestUserId = uc.UserId }).FirstOrDefault(); if (objChallengedetail != null) { if (objChallengedetail.ResultUnit.Equals("Time")) { objChallengedetail.Result = CommonApiBL.GetChallengeResultBasedOnResultUnit(objChallengedetail.Result); } if (!string.IsNullOrEmpty(objChallengedetail.Result)) { objChallengedetail.Result = objChallengedetail.Result.Trim(); } if (!string.IsNullOrEmpty(objChallengedetail.ChallengeType)) { objChallengedetail.ChallengeType = objChallengedetail.ChallengeType.Split(' ')[0]; } if (objChallengedetail.CreatedByUserType.Equals(Message.UserTypeTrainer, StringComparison.OrdinalIgnoreCase)) { var objTrainer = _dbContext.Trainer.FirstOrDefault(t => t.TrainerId == objChallengedetail.CreatedByTrainerId); if (objTrainer != null) { objChallengedetail.CreatedByTrainerName = objTrainer.FirstName + " " + objTrainer.LastName; objChallengedetail.CreatedByProfilePic = string.IsNullOrEmpty(objTrainer.TrainerImageUrl) ? string.Empty : CommonUtility.VirtualPath + Message.ProfilePicDirectory + objTrainer.TrainerImageUrl; } } else { objChallengedetail.CreatedByTrainerId = 0; } } objChallengedetail.Excercises.ForEach( exer => { exer.WeightForMan = exer.WeightForManDB > 0 ? exer.WeightForManDB.ToString() + " " + ConstantHelper.constlbs : null; exer.WeightForWoman = exer.WeightForWomanDB > 0 ? exer.WeightForWomanDB.ToString() + " " + ConstantHelper.constlbs : null; exer.VedioLink = CommonUtility.VirtualFitComExercisePath + Message.ExerciseVideoDirectory + exer.VedioLink; exer.ExerciseThumnail = CommonWebApiBL.GetSaveExerciseThumbnail(exer.VedioLink, exer.ExerciseName); }); string tempdesc = string.Empty; if (objChallengedetail != null && !string.IsNullOrEmpty(objChallengedetail.VariableValue)) { tempdesc = CommonApiBL.GetChallengeVariableValueBasedVariableUnit(objChallengedetail.VariableValue, objChallengedetail.VariableUnit); } ////End the modification if (!string.IsNullOrEmpty(tempdesc)) { tempdesc = tempdesc.Trim(); } objChallengedetail.ChallengeDescription = objChallengedetail.ChallengeDescription.Replace("____", tempdesc) .Replace(ConstantHelper.constAmoutOfTime, ConstantHelper.constQustionMark). Replace(ConstantHelper.constAmoutOfTimeSecond, ConstantHelper.constQustionMark); if (objChallengedetail != null && !string.IsNullOrEmpty(objChallengedetail.VariableValue)) { objChallengedetail.VariableValue = CommonApiBL.GetChallengeVariableValueBasedOnTime(objChallengedetail.VariableValue); } tblCredentials objCredentials = _dbContext.Credentials.FirstOrDefault(c => c.Id == objChallengedetail.PersonalBestUserId); if (objCredentials != null) { objChallengedetail.PersonalBestUserName = CommonReportingUtility.GetUserFullNameBasedUserCredIdAndUserType(_dbContext, objCredentials.Id, objCredentials.UserType); } return(objChallengedetail); } catch { throw; } finally { traceLog.AppendLine("End GetSponsorChallengeDetails : --- " + DateTime.Now.ToLongDateString()); LogManager.LogManagerInstance.WriteTraceLog(traceLog); } } }
/// <summary> /// Function to update activity /// </summary> /// <returns>void</returns> /// <devdoc> /// Developer Name - Raghuraj Singh /// Date - 04/03/2015 /// </devdoc> public static void UpdateActivity(ActivityVM objActivityVM) { StringBuilder traceLog = null; using (LinksMediaContext dataContext = new LinksMediaContext()) { using (System.Data.Entity.DbContextTransaction tran = dataContext.Database.BeginTransaction()) { traceLog = new StringBuilder(); try { traceLog.AppendLine("Start: UpdateActivity for updating activity"); tblCredentials objCred = dataContext.Credentials.FirstOrDefault(c => c.UserId == objActivityVM.TrainerId && c.UserType == Message.UserTypeTrainer); int trainerCredId = objCred.Id; objActivityVM.TrainerId = trainerCredId; objActivityVM.ModifiedDate = DateTime.Now; tblActivity objActivity = dataContext.Activity.Where(ac => ac.ActivityId == objActivityVM.ActivityId).FirstOrDefault(); if (objActivity != null) { objActivity.AddressLine1 = objActivityVM.AddressLine1; objActivity.TrainerId = objActivityVM.TrainerId; objActivity.ModifiedDate = objActivityVM.ModifiedDate; objActivity.AddressLine2 = objActivityVM.AddressLine2; objActivity.DateOfEvent = objActivityVM.DateOfEvent; objActivity.Description = objActivityVM.Description; objActivity.NameOfActivity = objActivityVM.NameOfActivity; objActivity.Pic = objActivityVM.Pic; objActivity.PromotionText = objActivityVM.PromotionText; objActivity.State = objActivityVM.State; objActivity.Video = objActivityVM.Video; objActivity.Zip = objActivityVM.Zip; objActivity.LearnMore = objActivityVM.LearnMore; objActivity.City = Convert.ToInt32(objActivityVM.City); } dataContext.SaveChanges(); ///set activivty to featured queue in database if (objActivityVM.StartDate != null && objActivityVM.EndDate != null) { tblFeaturedActivityQueue featuredActivityQueue = dataContext.FeaturedActivityQueue.Where(ce => ce.ActivityId == objActivityVM.ActivityId).FirstOrDefault(); tblFeaturedActivityQueue featuredActivity = new tblFeaturedActivityQueue(); /*if featured activity is created then update else create new featured activity*/ if (featuredActivityQueue != null) { featuredActivityQueue.StartDate = objActivityVM.StartDate; featuredActivityQueue.ActivityId = objActivityVM.ActivityId; featuredActivityQueue.EndDate = objActivityVM.EndDate; } else { featuredActivity.StartDate = objActivityVM.StartDate; featuredActivity.ActivityId = objActivityVM.ActivityId; featuredActivity.EndDate = objActivityVM.EndDate; dataContext.FeaturedActivityQueue.Add(featuredActivity); } dataContext.SaveChanges(); } tran.Commit(); } catch { tran.Rollback(); throw; } finally { traceLog.AppendLine("UpdateActivity end() : --- " + DateTime.Now.ToLongDateString()); LogManager.LogManagerInstance.WriteTraceLog(traceLog); } } } }
/// <summary> /// Function to get post list on challenge completed(Comment Section) /// </summary> /// <returns>Total<List<ChallengeViewPostVM>></returns> /// <devdoc> /// Developer Name - Arvind Kumar /// Date - 05/13/2015 /// </devdoc> public static Total <List <ChallengeViewPostVM> > GetPostListForChallenge(int challengeId, int startIndex, int endIndex) { StringBuilder traceLog = null; using (LinksMediaContext _dbContext = new LinksMediaContext()) { try { traceLog = new StringBuilder(); traceLog.AppendLine("Start: ChallengeMessageFeedBL GetPostList"); Credentials userCredential = CommonWebApiBL.GetUserId(Thread.CurrentPrincipal.Identity.Name); List <ChallengeViewPostVM> objList = (from m in _dbContext.MessageStraems join c in _dbContext.Credentials on m.SubjectId equals c.Id where m.TargetId == challengeId && m.IsImageVideo && (!(string.IsNullOrEmpty(m.Content)) || m.IsImageVideo) && m.TargetType == Message.ChallengeTargetType && m.IsTextImageVideo == true orderby m.PostedDate descending select new ChallengeViewPostVM { PostId = m.MessageStraemId, DbPostedDate = m.PostedDate, Message = m.Content, BoomsCount = _dbContext.Booms.Count(b => b.MessageStraemId == m.MessageStraemId), CommentsCount = _dbContext.Comments.Count(cmnt => cmnt.MessageStraemId == m.MessageStraemId), PostedBy = m.SubjectId, UserId = _dbContext.Credentials.FirstOrDefault(crede => crede.Id == m.SubjectId).UserId, UserType = _dbContext.Credentials.FirstOrDefault(crede => crede.Id == m.SubjectId).UserType, IsLoginUserBoom = _dbContext.Booms.Where(bm => bm.MessageStraemId == m.MessageStraemId).Any(b => b.BoomedBy == userCredential.Id), IsLoginUserComment = _dbContext.Comments.Where(cm => cm.MessageStraemId == m.MessageStraemId).Any(b => b.CommentedBy == userCredential.Id), VideoList = (from vl in _dbContext.MessageStreamVideo where vl.MessageStraemId == m.MessageStraemId && !string.IsNullOrEmpty(vl.VideoUrl) select new VideoInfo { RecordId = vl.RecordId, VideoUrl = vl.VideoUrl }).ToList(), PicList = (from pl in _dbContext.MessageStreamPic where pl.MessageStraemId == m.MessageStraemId && !string.IsNullOrEmpty(pl.PicUrl) select new PicsInfo { PicId = pl.RecordId, PicsUrl = pl.PicUrl, ImageMode = pl.ImageMode, Width = pl.Width, Height = pl.Height }).ToList() }).ToList(); foreach (var item in objList) { tblCredentials objCred = _dbContext.Credentials.FirstOrDefault(cr => cr.Id == item.PostedBy); string imageUrl = string.Empty; if (objCred != null && objCred.UserType.Equals(Message.UserTypeUser, StringComparison.OrdinalIgnoreCase)) { tblUser userTemp = _dbContext.User.FirstOrDefault(usr => usr.UserId == objCred.UserId); if (userTemp != null) { imageUrl = string.IsNullOrEmpty(userTemp.UserImageUrl) ? string.Empty : CommonUtility.VirtualPath + Message.ProfilePicDirectory + userTemp.UserImageUrl; } } else if (objCred != null && objCred.UserType.Equals(Message.UserTypeTrainer, StringComparison.OrdinalIgnoreCase)) { tblTrainer trainerTemp = _dbContext.Trainer.FirstOrDefault(usr => usr.TrainerId == objCred.UserId); if (trainerTemp != null) { imageUrl = string.IsNullOrEmpty(trainerTemp.TrainerImageUrl) ? string.Empty : CommonUtility.VirtualPath + Message.ProfilePicDirectory + trainerTemp.TrainerImageUrl; } } item.PostedByImageUrl = imageUrl; item.UserName = (objCred.UserType.Equals(Message.UserTypeUser, StringComparison.OrdinalIgnoreCase) ? _dbContext.User.FirstOrDefault(usr => usr.UserId == objCred.UserId).FirstName + " " + _dbContext.User.FirstOrDefault(usr => usr.UserId == objCred.UserId).LastName : _dbContext.Trainer.FirstOrDefault(tnr => tnr.TrainerId == objCred.UserId).FirstName + " " + _dbContext.Trainer.FirstOrDefault(tnr => tnr.TrainerId == objCred.UserId).LastName); item.PostedDate = CommonWebApiBL.GetDateTimeFormat(item.DbPostedDate); //Code For Getting Posted Pics item.PicList.ForEach(pic => { pic.PicsUrl = (!string.IsNullOrEmpty(pic.PicsUrl) && System.IO.File.Exists(HttpContext.Current.Server.MapPath("~/" + Message.ResultPicDirectory + pic.PicsUrl))) ? CommonUtility.VirtualPath + Message.ResultPicDirectory + pic.PicsUrl : string.Empty; } ); string thumnailHeight, thumnailWidth; //Code For Getting Posted Videos item.VideoList.ForEach(vid => { string thumnailFileName = vid.VideoUrl.Split('.')[0] + Message.JpgImageExtension; vid.ThumbNailUrl = string.IsNullOrEmpty(vid.VideoUrl) ? string.Empty : CommonUtility.VirtualPath + Message.ResultVideoDirectory + vid.VideoUrl.Split('.')[0] + Message.JpgImageExtension; vid.VideoUrl = !string.IsNullOrEmpty(vid.VideoUrl) ? CommonUtility.VirtualPath + Message.ResultVideoDirectory + vid.VideoUrl : string.Empty; thumnailHeight = string.Empty; thumnailWidth = string.Empty; CommonWebApiBL.GetThumNailDemension(thumnailFileName, out thumnailHeight, out thumnailWidth); vid.ThumbNailHeight = thumnailHeight; vid.ThumbNailWidth = thumnailWidth; } ); } Total <List <ChallengeViewPostVM> > objresult = new Total <List <ChallengeViewPostVM> >(); objresult.TotalList = (from l in objList orderby l.DbPostedDate descending select l).Skip(startIndex).Take(endIndex - startIndex).ToList(); objresult.TotalCount = objList.Count(); if ((objresult.TotalCount) > endIndex) { objresult.IsMoreAvailable = true; } return(objresult); } catch { throw; } finally { traceLog.AppendLine("End :ChallengeMessageFeedBL GetPostList : --- " + DateTime.Now.ToLongDateString()); LogManager.LogManagerInstance.WriteTraceLog(traceLog); } } }