public ActionResult RefereralInfo(AgentReferences objData) { var data = this._reference.Find(x => x.Id == objData.ReferenceId) .Select(x => { var info = new AgentReferences() { ReferenceId = x.Id, FirstName = x.User.FirstName, LastName = x.User.LastName, Email = x.User.Email, Phone = x.User.MobileNumber, Address = x.User.Address, State = x.User.State.HasValue ? x.User.State.Value.ToString() : "0", Note = x.Note, IsContacted = x.IsContacted, IsInstersted = x.IsIntersted.HasValue ? x.IsIntersted.Value ? 1 : 0 : 2, IsAccepted = x.IsResponded, IsPaid = x.IsCommissionPaid }; return info; }).FirstOrDefault(); ViewBag.Active = "liReference"; return View(data); }
private List <AgentReferences> GetAllReferals(DateTime?FromDate, DateTime?ToDate) { var objData = this._reference.FindAll().Where(x => x.CreatedDate >= (FromDate != null ? FromDate:x.CreatedDate) && x.CreatedDate <= (ToDate != null ? ToDate:x.CreatedDate)) .Select(x => { var data = new AgentReferences() { ReferenceId = x.Id, FirstName = x.User.FirstName, LastName = x.User.LastName, Name = this._userRepository.FindOne(y => y.UserId == x.RefferedBy).FirstName + " " + this._userRepository.FindOne(y => y.UserId == x.RefferedBy).LastName, Email = x.User.Email, Phone = x.User.MobileNumber, Address = x.User.Address, State = x.User.State.HasValue ? x.User.State.Value.ToString() : "0", Status = x.Status, IsContacted = x.IsContacted.HasValue ? x.IsContacted.Value : false, IsInstersted = x.IsIntersted.HasValue ? x.IsIntersted.Value ? 1 : 0 : 2, IsAccepted = x.IsResponded.HasValue ? x.IsResponded.Value : false, IsPaid = x.IsCommissionPaid.HasValue ? x.IsCommissionPaid.Value : false }; return(data); }).OrderByDescending(x => x.ReferenceId).ToList(); return(objData); }
public ActionResult Reference() { var objData = this._reference.FindAll() .Where(x => x.RefferedBy == UserId) .Select(x => { var data = new AgentReferences() { ReferenceId = x.Id, Name = x.User.FirstName + " " + x.User.LastName, Email = x.User.Email, Phone = x.User.MobileNumber, State = x.User.State.ToString(), Status=x.Status }; return data; }).OrderByDescending(x=>x.ReferenceId).ToList(); ViewBag.TotalReference = this._reference.FindAll().Where(x => x.RefferedBy == UserId).Count(); ViewBag.Contacted = this._reference.FindAll().Where(x => x.RefferedBy == UserId && x.IsContacted==true).Count(); ViewBag.DealAccepted = this._reference.FindAll().Where(x => x.RefferedBy == UserId && x.IsResponded == true).Count(); ViewBag.Paid = this._reference.FindAll().Where(x => x.RefferedBy == UserId && x.IsCommissionPaid == true).Count(); ViewBag.NotContacted = this._reference.FindAll().Where(x => x.RefferedBy == UserId && (x.IsContacted == null || x.IsContacted==false)).Count(); ViewBag.Active = "liReference"; return View(objData); }
/// <summary> /// Exports the Data of Referals to the Excel between the Selected Dates. Default will be all,incase no date selected. /// </summary> /// <param name="objdata"></param> /// <returns></returns> public ActionResult ExportToExcell(AgentReferences objdata) { var objData = GetAllReferals(objdata.FromDate != null ? Convert.ToDateTime(objdata.FromDate): (DateTime?)null, objdata.ToDate != null ? Convert.ToDateTime(objdata.ToDate) : (DateTime?)null); System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("FirstName", typeof(string)); dt.Columns.Add("LastName", typeof(string)); dt.Columns.Add("ReferedBy", typeof(string)); dt.Columns.Add("Email", typeof(string)); dt.Columns.Add("Phone", typeof(string)); dt.Columns.Add("Address", typeof(string)); dt.Columns.Add("State", typeof(string)); dt.Columns.Add("Status", typeof(string)); foreach (var item in objData) { var rec = dt.NewRow(); rec["FirstName"] = item.FirstName; rec["LastName"] = item.LastName; rec["ReferedBy"] = item.Name; rec["Email"] = item.Email; rec["Phone"] = item.Phone.ToString(); rec["Address"] = item.Address; rec["State"] = item.State; rec["Status"] = item.Status; dt.Rows.Add(rec); } var grid = new System.Web.UI.WebControls.GridView(); grid.DataSource = dt; grid.DataBind(); Response.ClearContent(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls"); Response.ContentType = "application/ms-excel"; Response.Charset = ""; StringWriter sw = new StringWriter(); System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw); grid.RenderControl(htw); Response.Output.Write(sw.ToString()); Response.Flush(); Response.Clear(); Response.End(); return(RedirectToAction("Referals")); }
public ActionResult RefereralInfo_Post(AgentReferences objdata) { var data = this._reference.FindOne(x => x.Id == objdata.ReferenceId); data.User.Email = objdata.Email; data.User.MobileNumber = objdata.Phone; data.User.Address = objdata.Address; data.User.State = Convert.ToInt32(objdata.State); this._reference.Update(data); AgentReferences objRef = new AgentReferences(); objRef.ReferenceId = objdata.ReferenceId; return RedirectToAction("RefereralInfo", objRef); }
public ActionResult AddAdminNote(AgentReferences objData) { var data = new DataAccess.ReferenceNote(); data.Note = objData.Note; data.ReferenceId = objData.ReferenceId; data.CreatedOn = DateTime.Now; this._referenceNotes.Add(data); AgentReferences objAgentRef = new AgentReferences(); objAgentRef.ReferenceId = objData.ReferenceId; return(RedirectToAction("RefereralInfo", objAgentRef)); }
public ActionResult AddReference(AgentReferences objData) { if (objData.Id!=0) { var objAgentData = this._reference.FindOne(x => x.Refferee == objData.ReferenceId); objData.FirstName = objAgentData.User.FirstName; objData.LastName = objAgentData.User.LastName; objData.Address = objAgentData.User.Address; objData.State = objAgentData.User.State.HasValue ? objAgentData.User.State.Value.ToString() : "0"; objData.ZipCode = objAgentData.User.PinCode; } ViewBag.Active = "liReference"; return View(objData); }
public ActionResult Notifications() { var data = this._reference.FindAll() .Where(x => x.Flag == false) .Select(x => { var flagdata = new AgentReferences() { ReferenceId = x.Id, ReferedBy = this._userRepository.FindOne(y => y.UserId == x.RefferedBy).FirstName + " " + this._userRepository.FindOne(y => y.UserId == x.RefferedBy).LastName, Referee = x.User.FirstName + " " + x.User.LastName, Date = x.CreatedDate.ToString() }; return(flagdata); }).OrderByDescending(x => x.Id).ToList(); return(PartialView("_Notifications", data)); }
public ActionResult AddReference_Post(AgentReferences objData) { DataAccess.Reference objRef = new DataAccess.Reference(); DataAccess.User objuser = new DataAccess.User(); //Saves the Details of Referee to the User Table objuser.FirstName = objData.FirstName; objuser.LastName = objData.LastName; objuser.Address = objData.Address; objuser.State = Convert.ToInt32(objData.State); objuser.City = objData.City; objuser.PinCode = objData.ZipCode; objuser.MobileNumber = objData.Phone; objuser.IsDeleted = false; objuser.Email = objData.Email; objuser.IsReference = true; this._userRepository.Add(objuser); //Saves the Reference Details along with the UserID obtained into the Reference Table objRef.Note = objData.Note; objRef.RefferedBy = UserId; objRef.Refferee = objuser.UserId; objRef.IsContacted = false; objRef.Flag = false; objRef.Status = "Not Yet Contacted"; objRef.CreatedDate = DateTime.Now; this._reference.Add(objRef); #region Mailing Asynchronously //Asynchronously calls the SendMailToReferences method to send Mail AsyncMethodCaller caller = new AsyncMethodCaller(SendMailToReferences); //Sends the Mail to the Referee, stating been Refered caller.BeginInvoke(objuser.Email, base.Email ,string.Empty,"You have been Refererd","Test Body",null,null); //Sends the Mail to the Admin Regarding new notification caller.BeginInvoke(Core.BaseModel.AdminMail, string.Empty, string.Empty, "Notification About Referance", "Test Body", null, null); #endregion ViewBag.Active = "liReference"; return RedirectToAction("Reference"); }
public ActionResult RefereralInfo(AgentReferences objData) { var data = this._reference.Find(x => x.Id == objData.ReferenceId) .Select(x => { var info = new AgentReferences() { ReferenceId = x.Id, FirstName = x.User.FirstName, LastName = x.User.LastName, Name = this._userRepository.FindOne(y => y.UserId == x.RefferedBy).FirstName + " " + this._userRepository.FindOne(y => y.UserId == x.RefferedBy).LastName, Email = x.User.Email, Phone = x.User.MobileNumber, Address = x.User.Address, State = x.User.State.HasValue ? x.User.State.Value.ToString() : "0", Status = x.Status, Note = x.Note, IsContacted = x.IsContacted, IsInstersted = x.IsIntersted.HasValue ? x.IsIntersted.Value ? 1 : 0 : 2, IsAccepted = x.IsResponded, IsPaid = x.IsCommissionPaid, Notes = this._referenceNotes.FindAll().Where(y => y.ReferenceId == x.Id).OrderByDescending(y => y.Id) .Select(y => { var notedata = new AdminNotes() { NotesId = y.Id, CreatedOn = y.CreatedOn.ToString(), Notes = y.Note }; return(notedata); }).ToList() }; return(info); }).FirstOrDefault(); ViewBag.Active = "liReference"; UpdateFlagBit(objData.ReferenceId); return(View(data)); }
/// <summary> /// Updates the Column in the Data Base of Referals ( IsContacted, Is Accepted, Is Paid, Is Intersted ) /// </summary> /// <param name="objData"></param> /// <returns></returns> public JsonResult UpdateColumn(AgentReferences objData) { try { var data = this._reference.Find(x => x.Id == objData.ReferenceId).FirstOrDefault(); data.IsContacted = objData.IsContacted; data.IsResponded = objData.IsAccepted; data.IsCommissionPaid = objData.IsPaid; if (objData.IsInstersted != 2) { data.IsIntersted = objData.IsInstersted == 1 ?true:false; } data.Status = objData.Status; //data.GetType().GetProperty(objData.Column).SetValue(data, objData.IsChecked); this._reference.Update(data); return(Json("Success")); } catch { return(Json("Fail")); } }