// GET: Employee
        public async Task <ActionResult> Index()
        {
            var identityName = User.Identity.Name;
            var users        = _activeDirectoryUserDa.GetActiveDirectoryUsers().ToList()
                               .Select(p => AutoMapper.Mapper.Map <User>(p)).ToList();
            var adUsersMap = users.ToDictionary(key => key.id, value => value.displayName);
            var userID     = users.First(adUser => adUser.userPrincipalName == identityName).id;

            ViewBag.UserID      = userID;
            ViewBag.AssociateId = userID;
            var peersForGivenAssociate = _peersDa.GetAllPeersForGivenAssociate(userID);
            var employeeViewModels     = peersForGivenAssociate
                                         .Select(AutoMapper.Mapper.Map <EmployeeViewModel>)
                                         .ToList();
            var pcAssociateViewModel =
                AutoMapper.Mapper.Map <PCAssociateViewModel>(_pcAssocaiteDa.GetPCAssociateForGivenAssociateId(userID));

            pcAssociateViewModel.PCDisplayName              = adUsersMap[pcAssociateViewModel.PCUserId];
            pcAssociateViewModel.AssociateDisplayName       = adUsersMap[pcAssociateViewModel.PCUserId];
            employeeViewModels.ForEach(p => p.PeerName      = adUsersMap[p.PeerUserId]);
            employeeViewModels.ForEach(p => p.AssociateName = adUsersMap[p.AssociateUserId]);
            var viewModels = new EmployeeViewModels()
            {
                EmployeeModels       = employeeViewModels,
                PcAssociateViewModel = pcAssociateViewModel
            };

            return(View(viewModels));
        }
Beispiel #2
0
        public bool[] checkAttend(int month, EmployeeViewModels model)
        {
            //listMonth is attend of user for a month (31 days)
            //1st == listMonth[1]
            bool[] listMonth = new bool[model.numDays + 1];

            string logUserID = Session["logUserID"].ToString();

            List <Attent> list = db.Attents.Where(o => o.attent_user.Equals(logUserID)).ToList();

            //save to bool[]
            for (int i = 0; i < list.Count; i++)
            {
                int day = list[i].attent_time.Day;
                if (month == list[i].attent_time.Month)
                {
                    if (listMonth[day] == false && IsWeekend(list[i].attent_time))
                    {
                        model.countWk++;
                    }
                    listMonth[day] = true;
                }
            }
            return(listMonth);
        }
Beispiel #3
0
 public ActionResult Login(EmployeeViewModels model)
 {
     if (model.Email == null || model.Password == null)
     {
         ViewData["Error"] = "Hãy điền đầy đủ các trường";
     }
     else
     {
         var employee = db
                        .employees
                        .SingleOrDefault
                        (
             n => (n.employee_email == model.Email.ToLower() &&
                   n.employee_password == Utility.ComputeSha256Hash(model.Password))
                        );
         if (employee != null)
         {
             if (employee.employee_role < 1)
             {
                 return(RedirectToAction("Login"));
             }
             Session["employee"] = employee;
             return(RedirectToAction("Index", "Employee"));
         }
         ViewData["Error"] = "Đăng nhập thất bại";
     }
     return(View(model));
 }
        public ActionResult 人員檢視()
        {
            MotaiDataEntities dbContext = new MotaiDataEntities();

            if (Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] == null)
            {
                return(RedirectToAction("員工登入", "Employee"));
            }
            tEmployee empse   = Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] as tEmployee;
            var       empall  = dbContext.tEmployees.OrderBy(c => c.eBranch).ToList();
            var       empall2 = empall.OrderBy(c => c.ePosition).ToList();
            var       empall3 = empall2.OrderBy(c => c.eBranch).ToList();
            List <EmployeeViewModels> employees = new List <EmployeeViewModels>();

            foreach (var item in empall3)
            {
                EmployeeViewModels employeeModel = new EmployeeViewModels();
                employeeModel.EmployeeId = item.EmployeeId;
                employeeModel.eAccount   = item.eAccount;
                employeeModel.eName      = item.eName;
                employeeModel.sPosition  = item.tPosition.pPosition;
                employeeModel.sBranch    = item.tBranch.bBranch;
                employees.Add(employeeModel);
            }
            return(View(employees));
        }
Beispiel #5
0
        // GET: Employee
        public ActionResult Index()
        {
            if (Session["logUserID"] == null)
            {
                return(RedirectToAction("Logout", "Users"));
            }

            EmployeeViewModels model = new EmployeeViewModels();

            model.monthAttend = checkAttend(DateTime.Now.Month, model);
            string userID = Session["logUserID"].ToString();

            foreach (var item in db.Attents.Where(u => u.attent_user.Equals(userID)))
            {
                AttendViewModel at = new AttendViewModel();
                User            us = db.Users.Find(item.attent_user);
                at.user_id  = item.attent_user;
                at.fullname = us.full_name;
                at.log_time = item.attent_time;
                at.location = db.Devices.Find(item.attent_device).description;
                model.listAttent.Add(at);
            }

            model.countWd  = model.monthAttend.Where(d => d == true).Count() - model.countWk;
            model.percenWk = (double)model.countWk / CountWeekend() * 100;
            model.percenWd = (double)model.countWd / (model.numDays - CountWeekend()) * 100;

            ViewBag.totalWd = model.numDays - CountWeekend();
            ViewBag.totalWk = CountWeekend();

            return(View(model));
        }
        public void EditEmployee()
        {
            string submit = "Update";

            Employee employee = new Employee();

            {
                employee.First_Name  = "Troy";
                employee.Father_Name = "Plus";
            }

            mockEmployeeRepository.Setup(m => m.EditExistingEmployee(employee)).Returns(true);

            var employeelist = new EmployeeViewModels();

            {
                employee.First_Name  = "Troy";
                employee.Father_Name = "Plus";
            }
            employeelist.Employee = employee;

            // Now invoke the Index action.
            var actionResult = employeecontroller.Index(submit, employeelist);

            // Validate the expected result.
            ViewResult expectedResult = new ViewResult();

            Assert.IsNotNull(actionResult);
            //(branchList, (actionResult.Model as BranchViewModels).BranchList);
        }
        public IHttpActionResult EditEmployee(int id, EmployeeViewModels data)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != data.employee.EmployeeId)
            {
                return(BadRequest());
            }

            db.Entry(data.employee).State           = EntityState.Modified;
            db.Entry(data.employeeDependency).State = EntityState.Modified;
            db.Entry(data.position).State           = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }
        public ActionResult Edit(EmployeeViewModels model)
        {
            if (ModelState.IsValid)
            {
                var employee = repository.Find(model.EmployeeId);

                if (employee == null)
                {
                    this.BoostrapAlertWarning("No encontro el empleado que desea editar");
                    return(RedirectToAction("Index"));
                }

                MapperHelper.Map(model, employee);
                repository.Update(employee);

                if (model.Avatar != null)
                {
                    var imageName = fileUpload.SaveImageFile(model.Avatar, employee.UrlAvatar);
                    if (imageName != null)
                    {
                        employee.UrlAvatar = imageName;
                        repository.Update(employee);
                    }
                }

                this.BoostrapAlertSuccess(string.Format("Ha actualizado al empleado {0} {1}", employee.FirstName, employee.LastName));
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public void Add(EmployeeViewModels model)
        {
            Employee employee = new Employee();

            employee.Employee_ID = Guid.NewGuid();

            Repository.Add(Mapper.ModelToData(employee, model));
            Repository.Save();
        }
        public async Task <ActionResult> UpdateSelfAppraisal(EmployeeViewModels employeeViewModels)
        {
            var pcAssociate     = _pcAssocaiteDa.GetPCAssociate(employeeViewModels.PcAssociateViewModel.PCAssociatesId);
            var appraisalSeason = _appraisalProcessDa.GetAppraisalSeason(employeeViewModels.PcAssociateViewModel.AppraisalSeasonId);
            var name            = employeeViewModels.PcAssociateViewModel.AssociateDisplayName + " - SelfAppraisalForm - " + appraisalSeason.Name;
            var path            = await _fileService.UploadFile(employeeViewModels.SelfAppraisalDocument, name, appraisalSeason.Name);

            pcAssociate.SelfAppraisalDocumentUrl = path;
            _pcAssocaiteDa.EditPCAssociate(pcAssociate);
            return(RedirectToAction("Index"));
        }
        public ActionResult Details(string id)
        {
            EmployeeViewModels model = Service.GetById(id);

            if (model == null)
            {
                return(new HttpStatusCodeResult(404));
            }

            return(View(model));
        }
Beispiel #12
0
        public ActionResult EmployeeCreate(EmployeeViewModels data)
        {
            EmployeeBussines.GetEmployeeResponse request = new EmployeeBussines.GetEmployeeResponse()
            {
                Employee = data.Employee
            };

            result = EmployeeBussines.Insert.Employee(request).Message;

            return(RedirectToAction("EmployeeView", new { successful = true, ResultAction = "All Changes was successful" }));
        }
        public ActionResult SearchUser(EmployeeViewModels model)
        {
            try
            {
                var data = _Empfactory.GetListEmployee(model.StoreID, null, CurrentUser.ListOrganizationId);
                List <EmployeeModels> lstNews = new List <EmployeeModels>();
                foreach (var item in data)
                {
                    item.ImageURL = string.IsNullOrEmpty(item.ImageURL) ? Commons.Image100_100 : item.ImageURL;
                    //if (item.ListEmpStore != null && item.ListEmpStore.Any())
                    for (int i = 0; i < item.ListEmpStore.Count; i++)
                    {
                        if (i == 0)
                        {
                            item.StoreName = item.ListEmpStore[i].StoreName;
                            item.StoreID   = item.ListEmpStore[i].StoreID;
                            //============
                            //var lstRoleId = _UserRoleFactory.GetDataEmployee(item.ID).Select(x => x.RoleID).ToList();
                            item.RoleName = _ROfactory.ListRoleNameByEmp(item.ID, item.StoreID);
                        }
                        else
                        {
                            var newItem = new EmployeeModels();
                            newItem.ID        = item.ID;
                            newItem.Name      = item.Name;
                            newItem.Email     = item.Email;
                            newItem.RoleID    = item.RoleName;
                            newItem.ImageData = item.ImageData;
                            newItem.ImageURL  = item.ImageURL;
                            newItem.StoreName = item.ListEmpStore[i].StoreName;
                            newItem.StoreID   = item.ListEmpStore[i].StoreID;
                            //var lstRoleId = _UserRoleFactory.GetDataEmployee(item.ID).Select(x => x.RoleID).ToList();
                            newItem.RoleName = _ROfactory.ListRoleNameByEmp(newItem.ID, newItem.StoreID);

                            lstNews.Add(newItem);
                        }
                    }
                }
                data.AddRange(lstNews);
                var currentUser = (UserSession)System.Web.HttpContext.Current.Session["User"];
                if (currentUser != null)
                {
                    data = data.Where(ww => currentUser.ListStoreID.Contains(ww.StoreID)).ToList();
                }
                model.ListItem = data;
            }
            catch (Exception e)
            {
                _logger.Error("Account_Search: " + e);
                return(new HttpStatusCodeResult(400, e.Message));
            }
            return(PartialView("_ListDataUser", model));
        }
        public void saveEmployee()
        {
            string submit = "Save";

            /*
             *  First identify the repository methods which are invoked form Index action. Then Setup the mock
             *  for all the identified methods.
             *
             *  Then invoke the Controller's Index action with necessary input parameters and ensure that you have
             *  invoked the Index action for all the different cases (code blocks) available in that, which should
             *  cover all the blocks/statements in the Index action.
             *
             */
            #region Arrange
            // Prepare the return data for GetAllQuotation() method.
            Employee employee = new Employee();
            {
                employee.First_Name  = "Troy";
                employee.Father_Name = "Plus";
            }

            // Mock up the GetAllQuotation() repository method with expected return values.
            string initialID     = "Mr";
            string designationID = "Manager";
            string departmentID  = "IT";
            string branchID      = "Arapalayam";
            string leftreasonID  = "Resigned";

            mockEmployeeRepository.Setup(m => m.AddNewEmployee(employee)).Returns(true);
            mockEmployeeRepository.Setup(m => m.FindIdForInitial(initialID)).Returns(1);
            mockEmployeeRepository.Setup(m => m.FindIdForDesignationName(designationID)).Returns(1);
            mockEmployeeRepository.Setup(m => m.FindIdForDepartmentName(departmentID)).Returns(1);
            mockEmployeeRepository.Setup(m => m.FindIdForBranchName(branchID)).Returns(1);
            mockEmployeeRepository.Setup(m => m.FindIdForLeftReason(leftreasonID)).Returns(1);

            var employeelist = new EmployeeViewModels();
            {
                employee.First_Name  = "Troy";
                employee.Father_Name = "Plus";
            }
            employeelist.Employee = employee;

            #endregion

            // Now invoke the Index action.
            var actionResult = employeecontroller.Index(submit, employeelist);

            // Validate the expected result.
            ViewResult expectedResult = new ViewResult();

            Assert.IsNotNull(actionResult);
        }
Beispiel #15
0
        public ActionResult EmployeeCreate()
        {
            ViewBag.Title   = "New Employee";
            ViewBag.Message = "";

            var model = new EmployeeViewModels()
            {
                User     = UserBussines.Select.GetUserList().UserList,
                UserType = UserTypeBussines.Select.GetUserTypeList().UserTypeList
            };

            return(PartialView(model));
        }
Beispiel #16
0
 public ActionResult Index()
 {
     try
     {
         EmployeeViewModels model = new EmployeeViewModels();
         return(View(model));
     }
     catch (Exception ex)
     {
         NSLog.Logger.Error("Employee_Index Error: ", ex);
         return(new HttpStatusCodeResult(400, ex.Message));
     }
 }
Beispiel #17
0
 public ActionResult Search(EmployeeViewModels model)
 {
     try
     {
         var data = _factory.GetListEmployee();
         model.ListEmployee = data;
     }
     catch (Exception e)
     {
         NSLog.Logger.Error("GetListEmployee: ", e);
         return(new HttpStatusCodeResult(400, e.Message));
     }
     return(PartialView("_ListData", model));
 }
 //UserRole
 public ActionResult ViewAccounts()
 {
     try
     {
         EmployeeViewModels model = new EmployeeViewModels();
         ///GetListStoreGroup();
         return(View(model));
     }
     catch (Exception ex)
     {
         _logger.Error("ViewAccounts_Index: " + ex);
         return(new HttpStatusCodeResult(400, ex.Message));
     }
 }
        public IHttpActionResult AddEmployee(EmployeeViewModels data)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Employees.Add(data.employee);
            db.EmployeeDependencies.Add(data.employeeDependency);
            db.Positions.Add(data.position);
            db.SaveChanges();

            return(Ok());
        }
        public ActionResult CreateNewEmployee(EmployeeViewModels form)
        {
            if (!form.Password.Equals(form.RetypePassword))
            {
                ViewData["errorPass"] = "******";
            }
            else
            {
                if (Session["admin"] == null)
                {
                    return(RedirectToAction("Login", "Admin"));
                }
                account            thisAccount = (account)Session["admin"];
                HttpPostedFileBase file        = form.ImagePath;
                if (file != null && file.ContentLength > 0)
                {
                    string extend   = Path.GetExtension(file.FileName);
                    string fileName = Utility.ComputeSha256Hash((thisAccount.account_username)) + extend;
                    string path     = Path.Combine(Server.MapPath(Utility.PATH_IMG_EMPLOYEE), fileName);

                    employee newEmployee = new employee();

                    newEmployee.employee_name     = form.Name;
                    newEmployee.employee_email    = form.Email;
                    newEmployee.employee_dob      = form.Dob;
                    newEmployee.employee_gender   = form.Gender;
                    newEmployee.employee_phone    = form.Phone;
                    newEmployee.employee_address  = form.Address;
                    newEmployee.employee_password = Utility.ComputeSha256Hash(form.Password);

                    db.employees.InsertOnSubmit(newEmployee);
                    db.SubmitChanges();
                    newEmployee.employee_id = db.employees.OrderByDescending(u => u.employee_id).FirstOrDefault().employee_id;


                    employee_img employee_Img = new employee_img();
                    employee_Img.employee_id       = newEmployee.employee_id;
                    employee_Img.employee_img_path = Utility.CorrectPath(path);

                    file.SaveAs(path);
                    db.ExecuteQuery <employee_img>("insert into employee_img values ({0}, {1})", newEmployee.employee_id, employee_Img.employee_img_path);
                    //db.customer_imgs.InsertOnSubmit(customer_Img);
                    db.SubmitChanges();

                    return(RedirectToAction("Employee", "Admin"));
                }
            }
            return(View());
        }
Beispiel #21
0
        public ActionResult EmployeeView(bool successful = false, string ResultAction = "")
        {
            ViewBag.Title      = "Employees";
            ViewBag.successful = successful;
            ViewBag.Message    = ResultAction;

            var BussinesData = EmployeeBussines.Select.GetEmployeeList();
            var model        = new EmployeeViewModels()
            {
                Error        = BussinesData.Error,
                EmployeeList = BussinesData.EmployeeList
            };

            return(View(model));
        }
Beispiel #22
0
        public Employee ModelToData(Employee employee, EmployeeViewModels model)
        {
            employee.User_ID   = model.UserId;
            employee.FirstName = model.FirstName;
            employee.LastName  = model.LastName;
            employee.Email     = model.Email;
            employee.Telephone = model.Telephone;

            if (model.PoleId != null)
            {
                employee.Pole_ID = new Guid(model.PoleId);
            }

            return(employee);
        }
Beispiel #23
0
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmployeeViewModels user = db.Users.Where(u => u.Id == id).Select(u => new EmployeeViewModels {
                Id = u.Id, Email = u.Email, Role = "Reader"
            }).First();

            if (user == null)
            {
                return(HttpNotFound());
            }
            return(View(user));
        }
Beispiel #24
0
 public ActionResult 員工首頁()
 {
     if (Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] == null)
     {
         return(RedirectToAction("員工登入"));
     }
     else
     {
         tEmployee          emp      = Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] as tEmployee;
         EmployeeViewModels employee = new EmployeeViewModels();
         employee.EmployeeId = emp.EmployeeId;
         employee.eName      = emp.eName;
         employee.eAccount   = emp.eAccount;
         return(View(employee));
     }
 }
Beispiel #25
0
        public ActionResult Search(EmployeeViewModels model)
        {
            try
            {
                var data = _factory.GetListEmployee(CurrentUser.UserId, CurrentUser.RoleLevel, model.SearchString);
                ViewBag.CurrentUserId = CurrentUser.UserId;
                model.ListItem        = data;
            }
            catch (Exception e)
            {
                NSLog.Logger.Error("Employee_Search Error: ", e);
                return(new HttpStatusCodeResult(400, e.Message));
            }

            return(PartialView("_ListData", model));
        }
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser
                {
                    UserName    = model.UserName,
                    Email       = model.Email,
                    PhoneNumber = model.Telephone
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await this.UserManager.AddToRoleAsync(user.Id, model.Role);

                    if (model.Role != "Employee")
                    {
                        UserManager.AddToRole(user.Id, "Employee");
                    }

                    EmployeeService    service  = new EmployeeService();
                    EmployeeViewModels employee = new EmployeeViewModels();
                    employee.LastName  = model.LastName;
                    employee.FirstName = model.FirstName;
                    employee.Email     = model.Email;
                    employee.Telephone = model.Telephone;
                    employee.UserId    = user.Id;

                    service.Add(employee);

                    // Pour plus d'informations sur l'activation de la confirmation du compte et la réinitialisation du mot de passe, consultez http://go.microsoft.com/fwlink/?LinkID=320771
                    // Envoyer un message électronique avec ce lien
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirmez votre compte", "Confirmez votre compte en cliquant <a href=\"" + callbackUrl + "\">ici</a>");

                    return(RedirectToAction("Index", "Employee"));
                }
                ViewBag.Role = new SelectList(context.Roles.ToList(), "Name", "Name");

                AddErrors(result);
            }

            // Si nous sommes arrivés là, un échec s’est produit. Réafficher le formulaire
            return(View(model));
        }
Beispiel #27
0
        public ActionResult Edit(EmployeeViewModels user)
        {
            if (ModelState.IsValid)
            {
                var editedUser = db.Users.Where(u => u.Id == user.Id).First();
                editedUser.Email = user.Email;

                db.Entry(editedUser).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            EmployeeViewModels model = db.Users.Where(u => u.Id == user.Id).Select(u => new EmployeeViewModels {
                Id = u.Id, Email = u.Email, Role = "Reader"
            }).First();

            return(View(model));
        }
 public ActionResult 修改員工(EmployeeViewModels employee)
 {
     if (Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] != null)
     {
         MotaiDataEntities db  = new MotaiDataEntities();
         tEmployee         emp = db.tEmployees.Find(employee.EmployeeId);
         if (emp != null)
         {
             emp.eBranch   = employee.eBranch;
             emp.ePosition = employee.ePosition;
             emp.eName     = employee.eName;
             db.SaveChanges();
         }
         return(RedirectToAction("人員檢視"));
     }
     return(RedirectToAction("員工登入", "Employee"));
 }
        public HttpResponseMessage Post([FromBody] EmployeeViewModels employee)
        {
            if (ModelState.IsValid)
            {
                if (_employee.CheckEmployeeExits(employee.FirstName))
                {
                    var response = new HttpResponseMessage()
                    {
                        StatusCode = HttpStatusCode.Conflict
                    };

                    return response;
                }
                else
                {
                    var userId = this.User.FindFirstValue(ClaimTypes.Name);
                    var tempEmployee = AutoMapper.Mapper.Map<Employee>(employee);
                    tempEmployee.FirstName = Convert.ToString("FirstName");
                    tempEmployee.LastName = Convert.ToString("LastName");
                    tempEmployee.Contact = Convert.ToString("Contact");
                    tempEmployee.Gender = Convert.ToString("Gender");
                    tempEmployee.CreatedDate = DateTime.Now;
                    tempEmployee.Createdby = Convert.ToInt32(userId);
                    _employee.InsertEmployee(tempEmployee);

                    var response = new HttpResponseMessage()
                    {
                        StatusCode = HttpStatusCode.OK
                    };

                    return response;
                }
            }
            else
            {
                var response = new HttpResponseMessage()
                {

                    StatusCode = HttpStatusCode.BadRequest
                };

                return response;
            }

        }
 public ActionResult Commodity首頁()
 {
     if (Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] == null)
     {
         return(RedirectToAction("員工登入", "Employee"));
     }
     else
     {
         MotaiDataEntities  dbContext = new MotaiDataEntities();
         tEmployee          emp       = Session[CSession關鍵字.SK_LOGINED_EMPLOYEE] as tEmployee;
         EmployeeViewModels employee  = new EmployeeViewModels();
         employee.EmployeeId = emp.EmployeeId;
         employee.eName      = emp.eName;
         employee.eAccount   = emp.eAccount;
         employee.sPosition  = emp.tPosition.pPosition;
         return(View(employee));
     }
 }