public chartViewModel GetContactBylabel(int adminId) { chartViewModel _item = new chartViewModel(); List <chartItem> item = new List <chartItem>(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var query = (from post in _idc.tblcontacts.Where(a => a.AdminId == adminId && a.IsActive == true) join t in _idc.tbllabels on post.LabelId equals t.Id select new { Post = post, t = t }).GroupBy(a => a.t.LableName). Select(o => new { name = o.Key, Count = o.Count() }).ToList(); foreach (var items in query) { chartItem chrt = new chartItem(); chrt.name = items.name; chrt.value = items.Count; item.Add(chrt); } _item.data = item; } catch (Exception ex) { } finally { _idc.Dispose(); } return(_item); }
public CalenderJobs GetAllTodayTskname(int adminid, DateTime startDate) { CalenderJobs _taskList = new Models.CalenderJobs(); List <calnderitems> _profile = new List <calnderitems>(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { SqlParameter[] sqlParams = new SqlParameter[] { new SqlParameter("@adminId", adminid), new SqlParameter("@date", startDate) }; var dt = SqlHelper.ExecuteDataset(_global.con, CommandType.StoredProcedure, "getTodaysTask", sqlParams); for (int i = 0; i < dt.Tables[0].Rows.Count; i++) { calnderitems _items = new Models.calnderitems(); _items.Name = dt.Tables[0].Rows[i]["Name"].ToString(); _items.Statusclass = GetClassbyid(Convert.ToInt32(dt.Tables[0].Rows[i]["StatusId"])); _profile.Add(_items); } _taskList.jobs = _profile; } catch (Exception ex) { } finally { _idc.Dispose(); } return(_taskList); }
public Labelitem getLablesByLabelid(int labelId) { Labelitem _item = new Labelitem(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var list = _idc.tbllabels.Where(a => a.Id == labelId).ToList(); foreach (var item in list) { _item.LabelId = item.Id; _item.Name = item.LableName; _item.description = item.Description; _item.Active = item.Isactive.Value; _item.Totalcontacts = item.TotalContacts.HasValue ? item.TotalContacts.Value : 0; } } catch (Exception ex) { } finally { _idc.Dispose(); } return(_item); }
public string AddChat(int userId, string text, int AdminId) { string mobile = ""; Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var contacts = _idc.tblcontacts.Where(a => a.ContactId == userId).FirstOrDefault(); mobile = contacts.phone; tblinbox tbl = new tblinbox { Body = text, userId = userId, CreatedDate = DateTime.Now, sender = AdminId, reciver = userId, isRead = true }; _idc.tblinboxes.InsertOnSubmit(tbl); _idc.SubmitChanges(); mobile = mobile + "_" + tbl.MsgId.ToString(); } catch (Exception ex) { } finally { _idc.Dispose(); } return(mobile); }
public chatModel getContactsByAdminid(int adminId) { chatModel _item = new chatModel(); List <chatitem> item = new List <Models.chatitem>(); List <msgItem> msgItem = new List <Models.msgItem>(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { int selected = 0; var contacts = _idc.tblcontacts.Where(a => a.AdminId == adminId && a.IsActive == true).OrderByDescending(a => a.ContactId).ToList(); foreach (var i in contacts) { chatitem tem = new chatitem(); tem.id = i.ContactId; tem.image = string.IsNullOrEmpty(i.ImagePath) ? "/assets/images/icon/staff.png" : i.ImagePath; tem.name = i.Name; selected = selected == 0 ? i.ContactId : selected; item.Add(tem); } _item.selectedId = selected; _item.chatList = item; } catch (Exception ex) { } finally { _idc.Dispose(); } return(_item); }
public Labelitem addNewLabel(int adminId, string LabelName, string description) { Labelitem _item = new Labelitem(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var list = _idc.tbllabels.Where(a => a.AdminId == adminId && a.Isactive == true && a.LableName == LabelName).ToList(); if (list.Count() > 0) { _item.Error = "Error : Label already exist with " + LabelName + " ,please choose any other name"; } else { var tbl = new tbllabel { AdminId = adminId, CreatedDate = DateTime.Now, Description = description, Isactive = true, LableName = LabelName, TotalContacts = 0 }; _idc.tbllabels.InsertOnSubmit(tbl); _idc.SubmitChanges(); _item.LabelId = tbl.Id; _item.Name = tbl.LableName; _item.description = tbl.Description; _item.Totalcontacts = 0; } } catch (Exception ex) { } finally { _idc.Dispose(); } return(_item); }
public string UpdateProfile(tbllogin _profile, string Image = null) { string msg = "Profile Updated Succesfully"; Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var person = _idc.tbllogins.Where(a => a.UserId == _profile.UserId).FirstOrDefault(); if (!string.IsNullOrEmpty(Image)) { person.Image = Image; } person.FirstName = _profile.FirstName; person.LastName = _profile.LastName; person.Address = _profile.Address; person.Company = _profile.Company; person.Email = _profile.Email; person.IsActive = "Y"; person.Occupation = _profile.Occupation; person.Password = _profile.Password; person.PhoneNumber = _profile.PhoneNumber; _idc.SubmitChanges(); } catch (Exception ex) { msg = "Error " + ex.Message; } finally { _idc.Dispose(); } return(msg); }
public int Validateregister(LoginViewModel _model) { Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); var usrId = 0; try { var id = _idc.tbllogins.Where(a => a.Email == _model.Email || a.PhoneNumber == _model.phoneNumber).ToList(); if (id.Count() == 0) { tbllogin login = new tbllogin { CreatedDate = DateTime.Now, Email = _model.Email, FirstName = _model.firstname, IsActive = "Y", LastName = _model.lastname, Password = _model.Password, PhoneNumber = _model.phoneNumber }; _idc.tbllogins.InsertOnSubmit(login); _idc.SubmitChanges(); usrId = login.UserId; } } catch (Exception ex) { return(0); } finally { _idc.Dispose(); } return(usrId); }
public LabelModel getAllLablesByAdminid(int adminId) { LabelModel _profile = new Models.LabelModel(); List <Labelitem> _listitem = new List <Labelitem>(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var list = _idc.tbllabels.Where(a => a.AdminId == adminId && a.Isactive == true).ToList(); foreach (var item in list) { Labelitem _item = new Labelitem(); _item.LabelId = item.Id; _item.Name = item.LableName; _item.description = item.Description; _item.Totalcontacts = item.TotalContacts.HasValue ? item.TotalContacts.Value : 0; _listitem.Add(_item); } _profile._labelList = _listitem; } catch (Exception ex) { } finally { _idc.Dispose(); } return(_profile); }
public string updatejobbyId(tblJobMaster jobs) { string message = "Job Updated Succesfully"; Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var job = _idc.tblJobMasters.Where(a => a.Id == jobs.Id).FirstOrDefault(); job.AssignTo = jobs.AssignTo; job.Detail = jobs.Detail; job.EndDate = jobs.EndDate; job.Name = jobs.Name; job.PoNumber = jobs.PoNumber; job.StartDate = jobs.StartDate; job.StatusId = jobs.StatusId; job.TypeId = jobs.TypeId; job.IsActive = jobs.IsActive; _idc.SubmitChanges(); } catch (Exception ex) { message = "Error " + ex.Message; } finally { _idc.Dispose(); } return(message); }
public string upDateContact(tblcontact Contact) { string msg = string.Empty; tblcontact _item = new tblcontact(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var oldcontact = _idc.tblcontacts.Where(a => a.ContactId == Contact.ContactId).FirstOrDefault(); oldcontact.Age = Contact.Age; oldcontact.email = Contact.email; oldcontact.Name = Contact.Name; oldcontact.ImagePath = !string.IsNullOrEmpty(Contact.ImagePath) ? Contact.ImagePath : oldcontact.ImagePath; oldcontact.phone = Contact.phone; oldcontact.Role = Contact.Role; oldcontact.salary = Contact.salary; oldcontact.LabelId = Contact.LabelId; oldcontact.Joiningdate = Contact.Joiningdate; oldcontact.IsActive = Contact.IsActive; _idc.SubmitChanges(); } catch (Exception ex) { msg = "Error :" + ex.Message; } finally { _idc.Dispose(); } return(msg); }
public chartWeekModel GetJobByWeek(int adminId) { chartWeekModel _item = new chartWeekModel(); List <chartItem> pending = new List <chartItem>(); List <chartItem> closed = new List <chartItem>(); List <chartItem> problem = new List <chartItem>(); List <chartItem> newList = new List <chartItem>(); Global _global = new Database.Global(); DateTime mondayDate = DateTime .Today .AddDays(((int)(DateTime.Today.DayOfWeek) * -1) + 1); int monthcount = 7; CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var pjobs = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 2).ToList(); var cjobs = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 4).ToList(); var njobs = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 1).ToList(); var prjobs = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 3).ToList(); for (int i = 0; i < monthcount; i++) { chartItem pdata = new chartItem(); chartItem cdata = new chartItem(); chartItem ndata = new chartItem(); chartItem prdata = new chartItem(); pdata.value = pjobs.Where(a => a.CreatedDate.Value.Date == mondayDate.Date).Count(); cdata.value = cjobs.Where(a => a.CreatedDate.Value.Date == mondayDate.Date).Count(); ndata.value = njobs.Where(a => a.CreatedDate.Value.Date == mondayDate.Date).Count(); prdata.value = prjobs.Where(a => a.CreatedDate.Value.Date == mondayDate.Date).Count(); mondayDate = mondayDate.AddDays(1); pending.Add(pdata); closed.Add(cdata); problem.Add(prdata); newList.Add(ndata); } _item.Problem = problem; _item.New = newList; _item.pending = pending; _item.Completed = closed; } catch (Exception ex) { } finally { _idc.Dispose(); } return(_item); }
public JobViewModel getAlljobs(int adminId, int?statusid) { JobViewModel _profile = new Models.JobViewModel(); List <jobViewItem> _itemList = new List <jobViewItem>(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var jobs = _idc.tblJobMasters.Where(a => a.IsActive == true && a.OpenBy == adminId.ToString()); _profile.pending = jobs.ToList().Where(a => a.StatusId == 2).ToList().Count(); _profile.New = jobs.ToList().Where(a => a.StatusId == 1).ToList().Count(); _profile.problem = jobs.ToList().Where(a => a.StatusId == 3).ToList().Count(); _profile.complete = jobs.ToList().Where(a => a.StatusId == 4).ToList().Count(); var contacts = _idc.tbllogins.Where(a => a.UserId == adminId).FirstOrDefault(); var contactImage = string.IsNullOrEmpty(contacts.Image) ? "/assets/images/icon/staff.png" : contacts.Image; var query = from post in jobs.Where(a => (!statusid.HasValue || a.StatusId.Value == statusid)) join meta in _idc.tblcontacts on post.AssignTo equals meta.ContactId join s in _idc.tblstatus on post.StatusId equals s.Id join t in _idc.tbljobTypes on post.TypeId equals t.Id select new { Post = post, Meta = meta, s = s, t = t }; string image = "/assets/images/icon/staff.png"; foreach (var i in query) { jobViewItem _items = new Models.jobViewItem(); _items.AssignTo = i.Meta.Name; _items.AssignToImage = !string.IsNullOrEmpty(i.Meta.ImagePath) ? i.Meta.ImagePath : image; _items.OpenBy = contacts.FirstName; _items.OpenByImage = contactImage; _items.Date = i.Post.CreatedDate.ToString(); _items.Detail = i.Post.Detail; _items.JobId = i.Post.Id; _items.name = i.Post.Name; _items.Po = i.Post.PoNumber; _items.StatusId = i.Post.StatusId.Value; _items.Status = i.s.StatusName; _items.Type = i.t.Name; _itemList.Add(_items); } _profile._jobs = _itemList; } catch (Exception ex) { } finally { _idc.Dispose(); } return(_profile); }
public chartWeekModel GetJobByMonth(int adminId) { chartWeekModel _item = new chartWeekModel(); List <chartItem> pending = new List <chartItem>(); List <chartItem> closed = new List <chartItem>(); List <chartItem> problem = new List <chartItem>(); List <chartItem> newList = new List <chartItem>(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var pjobs = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 2).ToList(); var cjobs = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 4).ToList(); var njobs = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 1).ToList(); var prjobs = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 3).ToList(); int currentYear = DateTime.Now.Year; for (int i = 1; i <= 12; i++) { chartItem pdata = new chartItem(); chartItem cdata = new chartItem(); chartItem ndata = new chartItem(); chartItem prdata = new chartItem(); pdata.value = pjobs.Where(a => a.CreatedDate.Value.Month == i && a.CreatedDate.Value.Year == currentYear).Count(); cdata.value = cjobs.Where(a => a.CreatedDate.Value.Month == i && a.CreatedDate.Value.Year == currentYear).Count(); ndata.value = njobs.Where(a => a.CreatedDate.Value.Month == i && a.CreatedDate.Value.Year == currentYear).Count(); prdata.value = prjobs.Where(a => a.CreatedDate.Value.Month == i && a.CreatedDate.Value.Year == currentYear).Count(); pending.Add(pdata); closed.Add(cdata); problem.Add(prdata); newList.Add(ndata); } _item.Problem = problem; _item.New = newList; _item.pending = pending; _item.Completed = closed; } catch (Exception ex) { } finally { _idc.Dispose(); } return(_item); }
public void DeleteJobType(int jobtypeId) { Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var p = _idc.tbljobTypes.Where(a => a.Id == jobtypeId).FirstOrDefault(); p.IsActive = false; _idc.SubmitChanges(); } catch (Exception ex) { } finally { _idc.Dispose(); } }
public void deletelabel(int labelId) { Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var label = _idc.tbllabels.Where(a => a.Id == labelId).FirstOrDefault(); label.Isactive = false; _idc.SubmitChanges(); } catch (Exception ex) { } finally { _idc.Dispose(); } }
public tblcontact getContactsByContactid(int ContactId) { tblcontact _item = new tblcontact(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { _item = _idc.tblcontacts.Where(a => a.ContactId == ContactId).FirstOrDefault(); } catch (Exception ex) { } finally { _idc.Dispose(); } return(_item); }
public void Deletuser(int id) { Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var user = _idc.tbllogins.Where(a => a.UserId == id).FirstOrDefault(); user.IsActive = "N"; _idc.SubmitChanges(); } catch (Exception ex) { } finally { _idc.Dispose(); } }
public ContactViewModal GetaAllContactsByAdminId(int adminId) { ContactViewModal _item = new ContactViewModal(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var item = _idc.tblcontacts.Where(a => a.AdminId == adminId && a.IsActive == true).ToList(); _item.Contacts = item; } catch (Exception ex) { } finally { _idc.Dispose(); } return(_item); }
public void UpdateEventDate(int id, string startDate, string EndDate) { Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var job = _idc.tblJobMasters.Where(a => a.Id == id).FirstOrDefault(); job.StartDate = startDate.ToDateTime(); job.EndDate = EndDate.ToDateTime(); _idc.SubmitChanges(); } catch (Exception ex) { } finally { _idc.Dispose(); } }
public StatusViewModel getAllStatus() { StatusViewModel _profile = new Models.StatusViewModel(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var p = _idc.tblstatus.ToList(); _profile.statusList = p; } catch (Exception ex) { } finally { _idc.Dispose(); } return(_profile); }
public jobtypeViewModal getAllJobtypes(int adminId) { jobtypeViewModal _profile = new Models.jobtypeViewModal(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var p = _idc.tbljobTypes.Where(a => a.AdminId == adminId && a.IsActive == true).ToList(); _profile.jobtype = p; } catch (Exception ex) { } finally { _idc.Dispose(); } return(_profile); }
public tblJobMaster GetjobbyId(int id) { tblJobMaster _profile = new tblJobMaster(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var p = _idc.tblJobMasters.Where(a => a.Id == id).FirstOrDefault(); return(p); } catch (Exception ex) { } finally { _idc.Dispose(); } return(_profile); }
public chatModel getChatBychatId(int chatid, int adminId) { chatModel _item = new chatModel(); List <chatitem> item = new List <Models.chatitem>(); List <msgItem> msgItem = new List <Models.msgItem>(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var contacts = _idc.tbllogins.Where(a => a.UserId == adminId && a.IsActive == "y").FirstOrDefault(); var contactImage = string.IsNullOrEmpty(contacts.Image) ? "/assets/images/icon/staff.png" : contacts.Image; var query = from post in _idc.tblinboxes.Where(a => a.MsgId == chatid) join meta in _idc.tblcontacts on post.userId equals meta.ContactId select new { Post = post, Meta = meta }; string image = "/assets/images/icon/staff.png"; foreach (var i in query) { msgItem tem = new msgItem(); _item.xid = i.Post.userId.Value; tem.userId = i.Post.userId.Value; tem.sender = i.Post.sender.Value; tem.message = i.Post.Body; tem.messageId = i.Post.MsgId; tem.Image = i.Post.sender != i.Meta.ContactId ? contactImage : string.IsNullOrEmpty(i.Meta.ImagePath) ? image : i.Meta.ImagePath; tem.Name = i.Post.sender != i.Meta.ContactId ? contacts.FirstName : i.Meta.Name; tem.Time = i.Post.CreatedDate.Value.ToString("hh:mm tt"); msgItem.Add(tem); } _item.msgItem = msgItem; } catch (Exception ex) { } finally { _idc.Dispose(); } return(_item); }
public void deleteContact(int contactId) { Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var list = _idc.tblcontacts.Where(a => a.ContactId == contactId).FirstOrDefault(); var label = _idc.tbllabels.Where(a => a.Id == list.LabelId).FirstOrDefault(); label.TotalContacts = label.TotalContacts - 1; list.IsActive = false; _idc.SubmitChanges(); } catch (Exception ex) { } finally { _idc.Dispose(); } }
public chartViewModel GetJobByStatus(int adminId) { chartViewModel _item = new chartViewModel(); List <chartItem> item = new List <chartItem>(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var pending = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 2).Count(); var NewJobs = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 1).Count(); var problem = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 3).Count(); var Completed = _idc.tblJobMasters.Where(a => a.OpenBy == adminId.ToString() && a.IsActive == true && a.StatusId == 4).Count(); chartItem i = new chartItem(); i.name = "Pending"; i.value = pending; item.Add(i); chartItem i1 = new chartItem(); i1.name = "New"; i1.value = NewJobs; chartItem i2 = new chartItem(); i2.name = "Problem"; i2.value = problem; chartItem i3 = new chartItem(); i3.name = "Completed"; i3.value = Completed; item.Add(i1); item.Add(i2); item.Add(i3); _item.data = item; } catch (Exception ex) { } finally { _idc.Dispose(); } return(_item); }
public profile getProfileByUserId(int userId) { profile _profile = new Models.profile(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var p = _idc.tbllogins.Where(a => a.UserId == userId).FirstOrDefault(); _profile.Email = p.Email; _profile.image = p.Image; _profile.name = p.FirstName + " " + p.LastName; } catch (Exception ex) { } finally { _idc.Dispose(); } return(_profile); }
public int Validatelogin(string userName, string password) { Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var id = _idc.tbllogins.Where(a => a.Email == userName && a.Password == password).ToList(); if (id.Count() > 0) { return(id.FirstOrDefault().UserId); } else { return(0); } } catch (Exception ex) { string path = HttpContext.Current.Server.MapPath("~/App_Data/error.text"); if (!File.Exists(path)) { File.Create(path).Dispose(); using (TextWriter tw = new StreamWriter(path)) { tw.WriteLine(ex.Message); tw.Close(); } } return(0); } finally { _idc.Dispose(); } }
public string UpdateStatus(string color, string name, int id) { string message = "Status Updated Succesfully"; Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { var tbl = _idc.tblstatus.Where(a => a.Id == id).FirstOrDefault(); tbl.Color = color; tbl.StatusName = name; _idc.SubmitChanges(); } catch (Exception ex) { message = "Error " + ex.Message; } finally { _idc.Dispose(); } return(message); }
public tbllogin GetLoginUser(int userId) { tbllogin _profile = new tbllogin(); Global _global = new Database.Global(); CRMClassDataContext _idc = new Database.CRMClassDataContext(_global.con); try { _profile = _idc.tbllogins.Where(a => a.UserId == userId).FirstOrDefault(); if (string.IsNullOrEmpty(_profile.Image)) { _profile.Image = "~/assets/images/icon/staff.png"; } } catch (Exception ex) { } finally { _idc.Dispose(); } return(_profile); }