public JsonResult GetEvents()
        {
            Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
            int employeeID  = Convert.ToInt32(dictionary[1].Id == "" ? 0 : Convert.ToInt32(dictionary[1].Id));
            int userGroupID = Convert.ToInt32(dictionary[6].Id == "" ? 0 : Convert.ToInt32(dictionary[6].Id));

            //var events = dc.Appointments.Where(x => x.Status != "O" && x.Status != "C" && x.EmployeeID == employeeID).Select(x => new { x.VisitorName, x.Purpose, x.AppointmentDate, x.AppointmentTime, x.CompanyName }).ToList();

            //(x.EmployeeID == employeeID) &&
            using (IVMS_DBEntities dc = new IVMS_DBEntities())
            {
                //var groupCode = dc.UserGroups.Where(x => x.UserGroupId == userGroupID).Select(x => x.GroupCode).FirstOrDefault();
                var groupCode = dc.SEC_UserGroup.Where(x => x.ID == userGroupID).Select(x => x.GroupCode).FirstOrDefault();
                if (groupCode == "RECEPTION" || groupCode == "ADMIN")
                {
                    var events = dc.Appointments.Where(x => (x.Status == "A" || x.Status == "N" || x.Status == "AP" || x.Status == "P" || x.Status == "I")).Select(x => new { x.AppointmentBy, x.VisitorName, x.Purpose, x.AppointmentDate, x.AppointmentTime, x.CompanyName }).ToList();
                    return(new JsonResult {
                        Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
                else
                {
                    var events = dc.Appointments.Where(x => (x.EmployeeID == employeeID) && (x.Status == "A" || x.Status == "N" || x.Status == "AP" || x.Status == "P" || x.Status == "I")).Select(x => new { x.AppointmentBy, x.VisitorName, x.Purpose, x.AppointmentDate, x.AppointmentTime, x.CompanyName }).ToList();
                    return(new JsonResult {
                        Data = events, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    });
                }
            }
        }
Beispiel #2
0
        public JsonResult GetDeptWiseEmployee(int deptID)
        {
            Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
            IVMS_DBEntities db = new IVMS_DBEntities();

            try
            {
                if (deptID > 0)
                {
                    var employee = from b in db.Employees
                                   where b.Status == 1 && b.DepartmentID == deptID
                                   select new
                    {
                        b.EmployeeID,
                        b.EmpName
                    };
                    return(Json(employee, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception exception)
            {
                return(Json(new { success = false, message = exception.Message }, JsonRequestBehavior.AllowGet));
            }
            return(Json(null, JsonRequestBehavior.AllowGet));
        }
        public JsonResult OnBehalfEmployee(int?employeeID)
        {
            IVMS_DBEntities db = new IVMS_DBEntities();
            //result = new Result();
            //EmployeeFactory = new EmployeeFactorys();
            //List<DAL.db.Employee> list = EmployeeFactory.SearchEmployee(EmployeeID);

            var emp     = db.Employees.Where(x => x.OnBehalfEmployeeID == employeeID && x.EmployeeID != employeeID).ToList();
            var empList = emp.Select(x => new { x.EmployeeID, x.EmpName, x.BranchID, BranchName = x.SET_CompanyBranch.Name, x.DepartmentID, DepartmentName = x.Department.DepartmentName, x.DesignationID, DesignationName = x.Designation.DesignationName, x.Location, x.Floor, x.EmpCode, x.Mobile, x.PbxNumber, x.Email, x.OnBehalfEmployeeID });

            return(Json(empList, JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
        public JsonResult DepWiseEmployeeBehalf(int depID)
        {
            IVMS_DBEntities db         = new IVMS_DBEntities();
            int             employeeID = Convert.ToInt32(dictionary[1].Id == "" ? 0 : Convert.ToInt32(dictionary[1].Id));
            var             did        = (from e in db.Employees where e.EmployeeID == employeeID select e.DesignationID).FirstOrDefault();
            var             dcode      = (from d in db.Designations where d.DesignationID == did select d.Code).FirstOrDefault();

            //var bid = (from e in db.Employees where e.EmployeeID == employeeID select e.OnBehalfEmployeeID).FirstOrDefault();
            scheduleAppointmentFactory = new ScheduleAppointmentFactorys();
            List <Employee> list    = scheduleAppointmentFactory.SearchDepWiseEmployeeBehalf(depID, (int)employeeID);
            var             empList = list.Select(x => new { x.EmployeeID, EmpName = x.EmpName + " => " + x.Designation.DesignationName + " (Floor-" + x.Floor + ")", x.Floor, x.DesignationID });

            return(Json(empList, JsonRequestBehavior.AllowGet));
        }
Beispiel #5
0
        public JsonResult LoadNotifyList()
        {
            IVMS_DBEntities db         = new IVMS_DBEntities();
            int             employeeID = Convert.ToInt32(dictionary[1].Id == "" ? 0 : Convert.ToInt32(dictionary[1].Id));
            var             did        = (from e in db.Employees where e.EmployeeID == employeeID select e.DesignationID).FirstOrDefault();
            var             dcode      = (from d in db.Designations where d.DesignationID == did select d.Code).FirstOrDefault();

            if (dcode == "BEHALF")
            {
                //var onbhalfId = (from e in db.Employees where e.EmployeeID == employeeID select e.OnBehalfEmployeeID).FirstOrDefault();
                var appointmentList = from x in db.Appointments
                                      join e in db.Employees on x.EmployeeID equals e.EmployeeID
                                      where e.OnBehalfEmployeeID == employeeID && (x.Status == "N" || x.Status == "P")
                                      select new
                {
                    x.AppointmentBy,
                    x.AppointmentID,
                    x.AppointmentDate,
                    x.EmployeeID,
                    e.EmpName,
                    x.CompanyName,
                    x.Purpose,
                    x.AppointmentTime,
                    x.ReachTime,
                    x.Status,
                    x.VisitorName,
                    x.NotifyMessage,
                    x.ReplayMessage,
                    x.CreatedBy,
                    x.CreatedDate,
                    x.VisitorMobile,
                    x.VisitorEmail,
                    e.OnBehalfEmployeeID
                };
                //scheduleAppointmentFactory = new ScheduleAppointmentFactorys();

                //List<DAL.db.Appointment> list = scheduleAppointmentFactory.SearchNotifyDataPS((int)onbhalfId);
                //var appointmentList = list.Select(x => new { });
                return(Json(appointmentList, JsonRequestBehavior.AllowGet));
            }
            else
            {
                scheduleAppointmentFactory = new ScheduleAppointmentFactorys();
                List <DAL.db.Appointment> list = scheduleAppointmentFactory.SearchNotifyData(employeeID);
                var appointmentList            = list.Select(x => new { x.AppointmentBy, x.AppointmentID, x.AppointmentDate, x.EmployeeID, x.Employee.EmpName, x.CompanyName, x.Purpose, x.AppointmentTime, x.ReachTime, x.Status, x.VisitorName, x.VisitorMobile, x.VisitorEmail, x.NotifyMessage, x.ReplayMessage, x.CreatedBy, x.CreatedDate, x.Employee.OnBehalfEmployeeID });
                return(Json(appointmentList, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #6
0
        public bool SentMail(string toEmail, string companyName, string visitorName, string subject, string body)
        {
            string result = string.Empty;

            using (IVMS_DBEntities db = new IVMS_DBEntities())
            {
                var emailConfig = db.EmailConfigs.ToList().LastOrDefault();
                try
                {
                    SmtpClient client = new SmtpClient();
                    client.Timeout               = 30000;
                    client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                    client.UseDefaultCredentials = false;
                    client.Credentials           = new NetworkCredential(emailConfig.FromMailID, emailConfig.Pass);
                    client.Port      = emailConfig.Port;
                    client.Host      = emailConfig.Host;
                    client.EnableSsl = true;

                    string fromMail = emailConfig.FromMailID;
                    if (subject == string.Empty)
                    {
                        subject = "Visitor Waiting Notification";
                    }

                    if (body == string.Empty)
                    {
                        body = visitorName.Trim() + " " + "From" + " " + companyName.Trim() + " " + "wants to meet with you.";
                    }
                    MailMessage mail = new MailMessage(fromMail, toEmail, subject, body);
                    mail.BodyEncoding = UTF8Encoding.UTF8;
                    mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

                    client.Send(mail);
                    return(true);
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                    return(false);
                }
            }
        }
        public JsonResult EmployeeCreate(DAL.db.Employee emp, List <int> beHalfEmpList, UserModel user)
        {
            IVMS_DBEntities db = new IVMS_DBEntities();

            result = new Result();
            JsonResult jsonResult = new JsonResult();

            EmployeeFactory = new EmployeeFactorys();
            int companyID = Convert.ToInt32(dictionary[9].Id == "" ? 0 : Convert.ToInt32(dictionary[9].Id));

            emp.CompanyID = companyID;
            emp.Status    = 1;


            result = EmployeeFactory.SaveEmployee(emp);
            if (result.isSucess)
            {
                if (beHalfEmpList != null && beHalfEmpList.Count > 0)
                {
                    // Self OnBehalfEmployeeID
                    var appDataSelf = db.Employees.Where(x => x.EmployeeID == emp.EmployeeID).FirstOrDefault();
                    appDataSelf.OnBehalfEmployeeID = emp.EmployeeID;
                    db.Entry(appDataSelf).State    = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    foreach (var details in beHalfEmpList)
                    {
                        var appData = db.Employees.Where(x => x.EmployeeID == details).FirstOrDefault();
                        appData.OnBehalfEmployeeID = emp.EmployeeID;
                        db.Entry(appData).State    = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                    }
                }
                if (user.UserGroupID > 0)
                {
                    UserController userController = new UserController();
                    jsonResult = userController.CreateUserSave(user);
                }
            }
            return(Json(result));
        }
Beispiel #8
0
 public SecurityFactorys()
 {
     context = new IVMS_DBEntities();
 }
 public CompanyBranchFactorys()
 {
     db = new IVMS_DBEntities();
 }