internal bool CancelSession(UniqueRequestModel objReq) { using (var db = new WizzDataContext()) { try { db.tblStudentRequests.Where(x => x.uniqueStudentRequestId == objReq.uniqueRequestId).ToList().ForEach(x => x.isDelete = true); return true; } catch (Exception) { return false; } } }
public Response<string> CancelSession(UniqueRequestModel objReq) { Response<string> response = new Response<string>(); List<string> objResp = new List<string>(); try { objDbMethodV2 = new wizz.Dal.DbMethodsV2(); if (CheckRequestIsvalidornot(this.Request)) { if (ModelState.IsValid) { if (objDbMethodV2.CancelSession(objReq)) response.Create(true, Messages.FormatMessage(Messages.Success, "Session cancelled"), Messages.AppVersion, objResp); else response.Create(false, Messages.ErrorOccure, Messages.AppVersion, objResp); } else response.Create(false, ModelState.Values.FirstOrDefault().Errors.FirstOrDefault().ErrorMessage, Messages.AppVersion, objResp); } else response.Create(false, Messages.FormatMessage(Messages.InvalidReq), Messages.AppVersion, objResp); } catch (Exception ex) { object session = new JavaScriptSerializer().Serialize(objReq); LogManager.Error("Error occured while Processing Webservice request :{0}", ex, session, ex.Message); response.Create(false, Messages.FormatMessage(Messages.ErrorOccure), Messages.AppVersion, objResp); } return response; }
internal SessionResponseStudentModel GetSessionInfoForStudent(UniqueRequestModel objReq) { using (var db = new WizzDataContext()) { SessionResponseStudentModel sessObj = new SessionResponseStudentModel(); List<SessionResponseStudentModel> tutorList = new List<SessionResponseStudentModel>(); int userId = Convert.ToInt32(objReq.userId); tblInviteFriend friendsData = new tblInviteFriend(); friendsData = db.tblInviteFriends.Where(x => x.fkFriendId == userId).FirstOrDefault(); if (friendsData != null) { objReq.userId = Convert.ToString(friendsData.fkUserId); } var sessionList = db.usp_GetSessions(Convert.ToInt32(objReq.userId)).ToList(); foreach (var c in sessionList) { SessionResponseStudentModel model = new SessionResponseStudentModel(); if (db.tblInviteFriends.Any(x => x.fkUserId == Convert.ToInt32(objReq.userId) && x.isDelete == true)) continue; model.homeWork = c.homeWork; model.homeWorkDueDate = c.homeWorkDueDate; model.latitude = Convert.ToString(c.lat); model.location = c.location; model.longitude = Convert.ToString(c.longi); model.profilePic = c.profilePic; //model.sessionEndTime = c.; model.sessionStartTime = c.sessionStartTime; model.fromTime = ReverseTimeConversionMethod(c.fromTime); model.toTime = ReverseTimeConversionMethod(c.toTime); model.dayType = Convert.ToString(c.dayType); model.subjectName = c.subjectName.ToString(); model.tutorId = c.tutorId.ToString(); model.tutorName = c.tutorName; model.sessionId = c.uniqueRequestId; var friendData = db.usp_GetFriendsOfUser(c.uniqueRequestId).ToList(); foreach (var d in friendData) { FriendsListModel mod = new FriendsListModel(); if (d.fkFriendId == Convert.ToInt32(objReq.userId) || d.isDelete == false) continue; // pkId=Convert.ToString(d.fId), mod.friendId = Convert.ToString(d.fkFriendId); mod.friendName = d.frienName == "" ? d.userName : d.frienName; mod.amount = ""; // friendphoneNumber = d.friendPhone == "" ? d.phoneNum : d.friendPhone, mod.isConfirm = Convert.ToString(d.isConfirm); mod.profilePic = string.IsNullOrWhiteSpace(d.profilePic) ? "" : d.profilePic.IndexOf("http") >= 0 ? d.profilePic : Constants.imagepath + d.profilePic; model.friendsList.Add(mod); } //model.friendsList = (from d in db.usp_GetFriendsOfUser(c.uniqueRequestId) // select new // { // }).ToList(); tutorList.Add(model); } sessObj = tutorList.Where(x => x.sessionId == objReq.uniqueRequestId).FirstOrDefault(); return sessObj; } }
public Response<SessionResponseStudentModel> GetSessionInfoForStudent(UniqueRequestModel objReq) { Response<SessionResponseStudentModel> response = new Response<SessionResponseStudentModel>(); List<SessionResponseStudentModel> objResp = new List<SessionResponseStudentModel>(); try { Session obj = new Session(); if (CheckRequestIsvalidornot(this.Request)) { objDbMethodV2 = new Dal.DbMethodsV2(); objResp.Add(objDbMethodV2.GetSessionInfoForStudent(objReq)); if (objResp.Count > 0) response.Create(true, Messages.FormatMessage(Messages.Success, "Session List"), Messages.AppVersion, objResp); else response.Create(false, Messages.FormatMessage(Messages.NoRecord), Messages.AppVersion, objResp); } else { response.Create(false, Messages.FormatMessage(Messages.NotAllowedUser), Messages.AppVersion, objResp); } } catch (Exception ex) { object session = new JavaScriptSerializer().Serialize(objReq); LogManager.Error("Error occured while Processing Webservice request :{0}", ex, session, ex.Message); response.Create(false, Messages.FormatMessage(Messages.ErrorOccure), Messages.AppVersion, objResp); } return response; }
internal bool CancelSession(UniqueRequestModel objReq) { using (var db = new WizzDataContext()) { try { Int32 userId = Convert.ToInt32(objReq.userId); if (Convert.ToBoolean(objReq.isTutor)) { var sessionData = db.tblSessions.Where(x => x.pkSessionId == Convert.ToInt64(objReq.sessionId)).FirstOrDefault(); sessionData.isDelete = true; sessionData.isCancelled = true; } else { db.tblStudentRequests.Where(x => x.uniqueStudentRequestId == objReq.uniqueRequestId && x.fkUserId == userId).ToList().ForEach(x => x.isDelete = true); var friendData = db.tblInviteFriends.Where(x => x.uniqueRequestId == objReq.uniqueRequestId && x.isDelete == false).ToList(); if (friendData.Count == 0) { var sessionData = db.tblSessions.Where(x => x.pkSessionId == Convert.ToInt64(objReq.sessionId)).FirstOrDefault(); sessionData.isDelete = true; sessionData.isCancelled = true; } else { var userData = friendData.Where(x => x.fkFriendId == userId).FirstOrDefault(); userData.isDelete = true; } } db.SubmitChanges(); return true; } catch (Exception) { return false; } } }