public void SendMsg(string fromId, string toId, string strMsg) { //chatmsg.Add(new ChatMsgModel { fromId = fromId, toId = toId, strMsg = strMsg, createDte = DateTime.Now }); using (ApplicantDBEntities db = new ApplicantDBEntities()) { core_chat chatinfo = new core_chat { chatId = 0, msgfrom = fromId, msgto = toId, msg = strMsg, createdby = fromId, createddate = DateTime.Now, isread = 0 }; db.core_chat.Add(chatinfo); db.SaveChanges(); } foreach (var row in UsersList.Where(wr => wr.userId == toId)) { Clients.Client(row.connectionId).getChatMsg(fromId, toId, strMsg, DateTime.Now); } }
public int countUnreadMsg(string fromId, string toId) { using (ApplicantDBEntities db = new ApplicantDBEntities()) { var qMsg = db.core_chat.Where(wr => wr.msgfrom == fromId && wr.msgto == toId && wr.isread == 0).Count(); return(qMsg); } }
/// <summary> /// postApplicantLogin /// </summary> /// <param name="p1">Applicant ID</param> /// <param name="p2">Purpose</param> public void postApplicantLogin(string p1, string p2) { try { using (ApplicantDBEntities dbcontext = new ApplicantDBEntities()) { dbcontext.Sproc_AppoolCheckIn(p1, p2); } } catch (Exception ex) { throw ex; } }
public List <appool_ApplicantCheckIn> getApplicantLoginbyCode(string p) { try { using (ApplicantDBEntities dbcontext = new ApplicantDBEntities()) { var q = dbcontext.appool_ApplicantCheckIn.Where(aa => aa.applicant_id == p).ToList(); return(q); } } catch (Exception ex) { throw ex; } }
public void Viewmsg(string fromId, string toId, string toName) { List <ChatMsgModel> chatmsg = new List <ChatMsgModel>(); using (ApplicantDBEntities db = new ApplicantDBEntities()) { var qchatFromMe = db.core_chat.Where(wr => wr.msgfrom == fromId && wr.msgto == toId).OrderByDescending(aa => aa.createddate).Take(10).ToList(); var qchatToMe = db.core_chat.Where(wr => wr.msgfrom == toId && wr.msgto == fromId).OrderByDescending(aa => aa.createddate).Take(10).ToList(); foreach (var row in qchatFromMe.OrderBy(aa => aa.createddate)) { chatmsg.Add(new ChatMsgModel { fromId = row.msgfrom, toId = row.msgto, strMsg = row.msg, iconClass = "bubble bubble--alt", createDte = row.createddate }); } foreach (var row in qchatToMe.OrderBy(aa => aa.createddate)) { chatmsg.Add(new ChatMsgModel { fromId = row.msgfrom, toId = row.msgto, strMsg = "<img src='http://apps.fastgroup.biz/201pic/48px/" + toId + ".jpg' width='32' height='32' /> <strong>" + toName + "</strong><br/>" + row.msg, iconClass = "bubble", createDte = row.createddate }); } var msglist = chatmsg.OrderBy(aa => aa.createDte).ToList(); //begin:update msg status to read var qMsg = db.core_chat.Where(wr => wr.msgfrom == toId && wr.msgto == fromId && wr.isread == 0); foreach (var row in qMsg) { row.isread = 1; } db.SaveChanges(); //end: //begin: broard cast info var frindOnlineExceptMe = UsersList.Except(UsersList.Where(wr => wr.userId == fromId).ToList()).Select(aa => new { aa.userId, aa.userName, msgCount = countUnreadMsg(aa.userId, fromId) }).Distinct().ToList(); Clients.Caller.getOnline(frindOnlineExceptMe); Clients.Caller.getfriendmsg(msglist); //end: } }
public PromptModel checkBooking(string fname, string lname, DateTime bdate) { PromptModel pr = new PromptModel(); string applicantID = string.Empty; try { using (ApplicantDBEntities dbcontext = new ApplicantDBEntities()) { var qApplicantID = dbcontext.appool_applicant .Where(aa => aa.first_name == fname && aa.last_name == lname && EntityFunctions.TruncateTime(aa.birth_date) == EntityFunctions.TruncateTime(bdate)); if (qApplicantID.Count() > 0) { applicantID = qApplicantID.First().applicant_id; //set applicant id pr.applicantID = applicantID; //set applicantID in the model if (dbcontext.appool_booking.Where(aa => aa.applicant_id == applicantID).Count() > 0) { var currentdate = DateTime.Now.Date; var qCheckBookingExam = dbcontext.appool_booking.Where(aa => aa.applicant_id == applicantID && aa.exam_date == currentdate); var qCheckBookingInterview = dbcontext.appool_booking.Where(aa => aa.applicant_id == applicantID && aa.interview_date == currentdate); if (qCheckBookingExam.Count() > 0 && qCheckBookingInterview.Count() > 0) { //check if the user is already in logbox var userLogboxInterview = dbcontext.appool_ApplicantCheckIn .Where(aa => EntityFunctions.TruncateTime(aa.login_date) == EntityFunctions.TruncateTime(currentdate) && aa.applicant_id == applicantID && aa.purpose == "INTERVIEW") .Count(); var userLogboxExam = dbcontext.appool_ApplicantCheckIn .Where(aa => EntityFunctions.TruncateTime(aa.login_date) == EntityFunctions.TruncateTime(currentdate) && aa.applicant_id == applicantID && aa.purpose == "EXAM") .Count(); if (userLogboxInterview > 0 && userLogboxExam > 0) { pr.ifunctionVal = 1; pr.functionMsg = "Invalid: Duplicate log is not authorized!"; } else { postApplicantLogin(applicantID, "INTERVIEW"); postApplicantLogin(applicantID, "EXAM"); pr.ifunctionVal = 0; pr.functionMsg = "Thank's for coming..."; } } else if (qCheckBookingExam.Count() > 0 && qCheckBookingInterview.Count() == 0) { var userLogboxExam = dbcontext.appool_ApplicantCheckIn .Where(aa => EntityFunctions.TruncateTime(aa.login_date) == EntityFunctions.TruncateTime(currentdate) && aa.applicant_id == applicantID && aa.purpose == "EXAM") .Count(); if (userLogboxExam > 0) { pr.ifunctionVal = 1; pr.functionMsg = "Invalid: Duplicate log is not authorized!"; } else { postApplicantLogin(applicantID, "EXAM"); pr.ifunctionVal = 0; pr.functionMsg = "Thank's for coming..."; } } else if (qCheckBookingExam.Count() == 0 && qCheckBookingInterview.Count() > 0) { var userLogboxInterview = dbcontext.appool_ApplicantCheckIn .Where(aa => EntityFunctions.TruncateTime(aa.login_date) == EntityFunctions.TruncateTime(currentdate) && aa.applicant_id == applicantID && aa.purpose == "INTERVIEW") .Count(); if (userLogboxInterview > 0) { pr.ifunctionVal = 1; pr.functionMsg = "Invalid: Duplicate log is not authorized!"; } else { postApplicantLogin(applicantID, "INTERVIEW"); pr.ifunctionVal = 0; pr.functionMsg = "Thank's for coming..."; } } else { pr.ifunctionVal = 1; pr.functionMsg = "No Event."; } } else { pr.ifunctionVal = 1; pr.functionMsg = "Applicant Not Found!"; } } else { pr.ifunctionVal = 1; pr.functionMsg = "Applicant Not Found!"; } return(pr); } } catch (Exception ex) { pr.ifunctionVal = 1; pr.functionMsg = ex.Message; return(pr); } }