public void RouteQueueList(List <int> selectedQueueIds, int departmentID) { using (var db = new ModelDBContext()) { foreach (int queueID in selectedQueueIds) { var currentQueue = db.PropertyCases.Where(q => q.PropertyCaseID == queueID).First(); if (currentQueue.DepartmentID != departmentID) { //create history record shows the old and new departments //var queueHistory = new CaseHistory(); //queueHistory.CaseID = queueID; //queueHistory.RoutedFromDepartmentID = currentQueue.DepartmentID; //queueHistory.RoutedToDepartmentID = departmentID; //queueHistory.AssignedFromEmployeeID = currentQueue.EmployeeID; //queueHistory.EventDatetime = DateTime.Now; //db.QueueHistories.Add(queueHistory); currentQueue.DepartmentID = departmentID; currentQueue.EmployeeID = null; var inProgressQueueStatus = db.CaseStatus.FirstOrDefault(q => q.CaseStatusID == (int)QueueStatusEnum.InProgress); if (inProgressQueueStatus != null) { currentQueue.CaseStatusID = inProgressQueueStatus.CaseStatusID; } db.SaveChanges(); } } } }
public ActionResult CreateAccount(Account Ac) { try { using (ModelDBContext mvc = new ModelDBContext()) { if (Ac.UserName == null || Ac.PassWord == null) { } else if (mvc.Accounts.Where(x => x.UserName.Equals(Ac.UserName)).ToList().Count == 0) { if (ModelState.IsValid) { mvc.Accounts.Add(Ac); mvc.SaveChanges(); } } else { } } } catch { return(View("Index", Ac)); } return(View("Index", Ac)); }
private bool IsActiveuser_session(string sid, Employee user) { //string ssid = (sid == null) ? "null" : sid; //string sessionid = "0"; //string id = "0"; //id = (user == null) ? "0" : user.Id; //ModelDBContext db = new ModelDBContext(); //Employee emp = db.Employees.Find(id); //sessionid = (emp == null ) ? "0" : emp.SessionId ; //return ssid.Equals(sessionid) ? true : false; if (sid == null || user == null) { return(false); } else { if (user == null) { return(false); } string sessionid = new ModelDBContext().Employees.Find(user.Id).SessionId; return(sid.Equals(sessionid) ? true : false); } }
public ActionResult updatedeptinfo(string rep_id, string coll_point, string current_dept_code, string sid) { DepartmentList dept_to_update_coll_point; Employee rep; Employee current_rep; using (ModelDBContext db = new ModelDBContext()) { rep = db.Employees.Find(rep_id); //current_rep = db.Employees.Where(e => e.Designation == "Rep" && e.DepartmentCode == rep.DepartmentCode).FirstOrDefault(); //current_rep = db.Employees.Where(e => e.Id == db.DepartmentLists.Where(d => d.DepartmentCode == current_dept_code).FirstOrDefault().RepresentativeId).First(); //if (current_rep!=null) //{ // current_rep.Designation = "Employee"; //} dept_to_update_coll_point = db.DepartmentLists.Find(current_dept_code); //if (rep.Designation != "Head") //{ // rep.Designation = "Rep"; //} dept_to_update_coll_point.CollectionPoint = coll_point; dept_to_update_coll_point.RepresentativeId = rep_id; db.SaveChanges(); } Debug.WriteLine(dept_to_update_coll_point.DepartmentName + rep.FirstName + current_dept_code); //return View("Index", new { sid = sid}); return(RedirectToAction("editdeptinfo", new { sid = sid })); }
/// <summary> /// routes queue to a different department and saves history /// </summary> /// <param name="queueID">queue to route</param> /// <param name="departmentID">department to route to</param> public void RouteQueue(int queueID, int departmentID) { using (var db = new ModelDBContext()) { var currentQueue = db.Queues.Where(q => q.QueueID == queueID).First(); if (currentQueue.DepartmentID != departmentID) { //create history record shows the old and new departments var queueHistory = new QueueHistory(); queueHistory.QueueID = queueID; queueHistory.RoutedFromDepartmentID = currentQueue.DepartmentID; queueHistory.RoutedToDepartmentID = departmentID; queueHistory.AssignedFromEmployeeID = currentQueue.EmployeeID; queueHistory.EventDatetime = DateTime.Now; db.QueueHistories.Add(queueHistory); currentQueue.DepartmentID = departmentID; currentQueue.EmployeeID = null; var inProgressQueueStatus = db.QueueStatus.FirstOrDefault(q => q.QueueStatusID == (int)QueueStatusEnum.InProgress); if (inProgressQueueStatus != null) { currentQueue.QueueStatusID = inProgressQueueStatus.QueueStatusID; } db.SaveChanges(); } } }
public Queue Get(int queueID, bool includeDetails) { Queue queue; using (var db = new ModelDBContext()) { if (includeDetails) { queue = db.Queues.Where(q => q.QueueID == queueID) .Include(q => q.Document) .Include(q => q.Document.DocumentStatus) .Include(q => q.Document.DocumentSubType.DocumentType) .Include(q => q.Property) .Include(q => q.Property.PropertyClass) .Include(q => q.QueueStatus) .Include(q => q.Department) .Include(q => q.Employee) //.Include(q => q.QueueNotes) .First(); } else { queue = db.Queues.Where(q => q.QueueID == queueID).First(); } } return(queue); }
/// <summary> /// get all statuses /// </summary> /// <returns></returns> public List <QueueStatus> List() { using (var db = new ModelDBContext()) { return(db.QueueStatus.ToList()); } }
public ActionResult viewhistorybyitem(string sid) { Employee user = (Employee)Session["user"]; Dictionary <string, int> res_ = new Dictionary <string, int>(); using (ModelDBContext db = new ModelDBContext()) { //select ItemNumber, sum(Quantity) from RequisitionFormDetails where FormNumber in (select r.FormNumber from RequisitionForms r where r.EmployeeId in (select Id from Employee where DepartmentCode = 'CPSC') and r.Status = 'approved') group by RequisitionFormDetails.ItemNumber List <RequisitionFormDetail> lists = db.RequisitionFormDetails.Where(formd => (db.RequisitionForms.Where(rf => db.Employees.Where(emp => emp.DepartmentCode == user.DepartmentCode).Select(e => e.Id).ToList().Contains(rf.EmployeeId) && (rf.Status == "Approved" || rf.Status == "Read")).Select(fff => fff.FormNumber).ToList()).Contains(formd.FormNumber)).ToList(); foreach (var item in lists) { if (res_.ContainsKey(item.ItemNumber)) { res_[item.ItemNumber] = Convert.ToInt32(res_[item.ItemNumber]) + Convert.ToInt32(item.Quantity); } else { res_[db.StationeryCatalogs.Where(c => c.ItemNumber == item.ItemNumber).Select(e => e.Description).First()] = Convert.ToInt32(item.Quantity); } } }; ViewData["res_"] = res_; ViewData["sid"] = sid; return(View()); }
public List <Queue> List(bool includeDetails) { List <Queue> queues; using (var db = new ModelDBContext()) { db.Configuration.ProxyCreationEnabled = false; //db.Configuration.LazyLoadingEnabled = false; if (includeDetails) { queues = db.Queues .Include(q => q.Document) .Include(q => q.Document.DocumentStatus) .Include(q => q.Document.DocumentSubType.DocumentType) .Include(q => q.Property) .Include(q => q.QueueStatus) .Include(q => q.Department) .Include(q => q.Employee) .ToList(); } else { queues = db.Queues.ToList(); } } return(queues); }
public ActionResult editdeptinfo(string id, string sid) { Employee user = (Employee)Session["user"]; Employee hod; Employee current_rep; DepartmentList dept; List <Employee> emp_list; List <CollectionPoint> coll_list; using (ModelDBContext db = new ModelDBContext()) { hod = db.Employees.Find(user.Id); //current_rep = db.Employees.Where(e => e.Designation == "Rep" && e.DepartmentCode==user.DepartmentCode).FirstOrDefault(); //if (current_rep == null) //{ // current_rep = hod; //} dept = (DepartmentList)db.DepartmentLists.Where(d => d.DepartmentCode == hod.DepartmentCode).FirstOrDefault(); current_rep = db.Employees.Where(e => e.Id == db.DepartmentLists.Where(d => d.DepartmentCode == hod.DepartmentCode).FirstOrDefault().RepresentativeId).First(); emp_list = db.Employees.Where(e => e.DepartmentCode == hod.DepartmentCode && e.Designation != "Delegate").ToList(); coll_list = db.CollectionPoints.ToList(); } ViewData["current_rep"] = current_rep; ViewData["coll_list"] = coll_list; ViewData["hod"] = hod; ViewData["dept"] = dept; ViewData["emp_list"] = emp_list; ViewData["sid"] = sid; return(View()); }
public void DelegateUpdate(string emp_id, string hod_id, string from = "0001-01-01", string to = "0001-01-01") { Employee hod; Employee delegate_; Employee previous_delegate; using (ModelDBContext db = new ModelDBContext()) { hod = db.Employees.Find(hod_id); delegate_ = db.Employees.Where(e => e.Id == emp_id).FirstOrDefault(); previous_delegate = db.Employees.Where(e => e.DepartmentCode == hod.DepartmentCode && e.Designation == "Delegate").FirstOrDefault(); if (previous_delegate != null) { previous_delegate.Designation = "Employee"; previous_delegate.DelegateFrom = null; previous_delegate.DelegateTo = null; } if (delegate_.Designation != "Head") { delegate_.Designation = "Delegate"; delegate_.DelegateFrom = Convert.ToDateTime(from); delegate_.DelegateTo = Convert.ToDateTime(to); } db.SaveChanges(); } }
public ActionResult Chat() { var account = HttpContext.User.Identity.Name; ModelDBContext db = new ModelDBContext(); //ViewBag.UserName =db.User.Where(x=>x.Email == account).FirstOrDefault().FullName; return(View()); }
/// <summary> /// Create a role for the selected employee. /// </summary> /// <param name="employeeRole"></param> public void CreateEmployeeRole(EmployeeRole employeeRole) { using (var db = new ModelDBContext()) { db.EmployeeRoles.Add(employeeRole); db.SaveChanges(); } }
/// <summary> /// Edit specific role. /// </summary> /// <param name="role"></param> public void EditRole(Role role) { using (ModelDBContext db = new ModelDBContext()) { db.Entry(role).State = EntityState.Modified; db.SaveChanges(); } }
/// <summary> /// Add role to the system. /// </summary> /// <param name="role"></param> public void AddRole(Role role) { using (ModelDBContext db = new ModelDBContext()) { db.Roles.Add(role); db.SaveChanges(); } }
/// <summary> /// Delete a role from the system. /// </summary> /// <param name="id"></param> public void DeleteRole(int id) { using (ModelDBContext db = new ModelDBContext()) { Role role = db.Roles.Find(id); db.Roles.Remove(role); db.SaveChanges(); } }
/// <summary> /// Delete and employee role. /// </summary> /// <param name="id"></param> public void DeleteEmployeeRole(int id) { using (ModelDBContext db = new ModelDBContext()) { EmployeeRole employeeRole = db.EmployeeRoles.Find(id); db.EmployeeRoles.Remove(employeeRole); db.SaveChanges(); } }
/// <summary> /// Get role by role ID /// </summary> /// <param name="id"></param> /// <returns></returns> public Role GetRole(int?id) { Role role = null; using (var db = new ModelDBContext()) { role = db.Roles.Find(id); } return(role); }
/// <summary> /// Get the employee by user name. /// </summary> /// <param name="username"></param> /// <returns></returns> public Employee GetByUsername(string username) { Employee emp = null; using (var db = new ModelDBContext()) { emp = db.Employees.FirstOrDefault(u => string.Compare(u.UserName, username, System.StringComparison.OrdinalIgnoreCase) == 0); } return(emp); }
/// <summary> /// lists all employees /// </summary> /// <returns></returns> public List <Employee> ListEmployees() { List <Employee> employees; using (ModelDBContext db = new ModelDBContext()) { employees = db.Employees.ToList(); } return(employees); }
public ActionResult Index(string token) { ModelDBContext db = new ModelDBContext(); var enti = db.Paragraph.Find(1); var entity = db.User; var name = System.Web.HttpContext.Current.User.Identity.Name; ViewBag.Title = "Home Page"; return(View()); }
public JsonResult GetDeptEmployees(string user_id) { List <Employee> emp_list; Employee hod; using (ModelDBContext db = new ModelDBContext()) { hod = db.Employees.Find(user_id); emp_list = db.Employees.Where(e => e.DepartmentCode == hod.DepartmentCode).ToList(); } return(Json(new { data = emp_list.Select(item => new { EmployeeId = item.Id, EmployeeName = item.FirstName + " " + item.LastName }) }, JsonRequestBehavior.AllowGet)); }
public List <CaseType> List() { List <CaseType> caseTypes; using (var db = new ModelDBContext()) { caseTypes = db.CaseTypes .ToList(); } return(caseTypes); }
public ActionResult notify(string sid) { Employee user = (Employee)Session["user"]; List <RequisitionForm> notify_form_list; using (ModelDBContext db = new ModelDBContext()) { notify_form_list = db.RequisitionForms.Where(f => f.EmployeeId == user.Id && (f.Notification == "approved_by_hod" || f.Notification == "rejected_by_hod")).ToList(); } Session["count"] = null; return(RedirectToAction("index")); }
public int Update(Queue queue) { using (var db = new ModelDBContext()) { //var currentQueue = db.Queues.Where(q => q.QueueID == queue.QueueID).First(); db.Queues.Add(queue); db.SaveChanges(); } return(queue.QueueID); }
/// <summary> /// returns a list of all document statuses /// </summary> /// <returns></returns> public List <DocumentStatus> ListDocumentStatus() { List <DocumentStatus> documentStatuses; using (var db = new ModelDBContext()) { db.Configuration.ProxyCreationEnabled = false; documentStatuses = db.DocumentStatus.ToList(); } return(documentStatuses); }
/// <summary> /// Retrieve all the roles for specific user /// </summary> /// <param name="employeeID"></param> /// <returns></returns> public List <EmployeeRole> ListEmployeeRoles(int employeeID) { List <EmployeeRole> employeeRoles; using (ModelDBContext db = new ModelDBContext()) { employeeRoles = db.EmployeeRoles .Include(q => q.Role) .Where(q => q.EmployeeID == employeeID).ToList(); } return(employeeRoles); }
/// <summary> /// return the document for the specified id /// </summary> /// <param name="documentID">documentid for the document to return</param> /// <returns></returns> public string GetDocumentPath(int documentID) { string documentNumber; using (var db = new ModelDBContext()) { documentNumber = db.Documents.Select(d => d.DocumentNumber).First(); } string documentsFolder = Path.GetFullPath(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "../../Documents/")); return(@"\Documents\2017-123.pdf"); }
public ActionResult req_forms(string form_id, string notify, string sid) { if (notify == "seen") { using (ModelDBContext db = new ModelDBContext()) { db.RequisitionForms.Where(f => f.FormNumber == form_id).FirstOrDefault().Notification = "seen_by_hod"; db.SaveChanges(); } } Employee user = (Employee)Session["user"]; int count; List <RequisitionForm> notify_form_list; using (ModelDBContext db = new ModelDBContext()) { notify_form_list = db.RequisitionForms.Where(row => (db.Employees.Where(e => e.DepartmentCode == user.DepartmentCode).Select(f => f.Id).ToList().Contains(row.EmployeeId) && row.Notification == "sent_to_hod")).ToList(); count = db.RequisitionForms.Where(row => (db.Employees.Where(e => e.DepartmentCode == user.DepartmentCode).Select(f => f.Id).ToList().Contains(row.EmployeeId) && row.Notification == "sent_to_hod")).Count(); } Session["count"] = count; Session["notify_form_list"] = notify_form_list; List <RequisitionFormDetail> form_cart; RequisitionForm form; List <StationeryCatalog> items; Employee emp; DepartmentList dept; using (ModelDBContext db = new ModelDBContext()) { form = db.RequisitionForms.Find(form_id); form_cart = db.RequisitionFormDetails.Where(f => f.FormNumber == form_id).ToList(); items = db.StationeryCatalogs.ToList(); emp = db.Employees.Where(e => e.Id == form.EmployeeId).FirstOrDefault(); dept = db.DepartmentLists.Where(e => e.DepartmentCode == emp.DepartmentCode).FirstOrDefault(); } ViewData["form_cart"] = form_cart; ViewData["form_number"] = form_id; ViewData["emp"] = emp; ViewData["emp_dept"] = dept; ViewData["catalog_list"] = items; ViewData["sid"] = sid; if (form.Status == "Pending") { ViewData["req_pending_forms"] = true; } ViewData["req_form"] = form; return(View()); }
public void AssignEmployeeBulk(List <int> queueIDs, int employeeID) { using (var db = new ModelDBContext()) { var queueList = db.Queues.Where(q => queueIDs.Contains(q.QueueID)).ToList(); foreach (Queue q in queueList) { q.EmployeeID = employeeID; } db.SaveChanges(); } }