コード例 #1
0
        public async Task <ActionResult> EmployeeProfile(int id)
        {
            //by employee id we are getting all necesessery data to view
            Session["EmployeeID"] = id;
            var emp = await _dbEmployees.GetEmployeeByID(id);

            ViewBag.FullName  = emp.FullName;
            ViewBag.PhotoType = emp.PhotoType;
            ViewBag.EmpPhoto  = emp.Photo;
            ViewBag.City      = emp.LivingCity;
            var teamLead        = _dbTeamLeads.GetById(emp.TeamLeadID);
            var currentTeamLead = await _dbEmployees.GetEmployeeByID(teamLead.EmployeeID);

            ViewBag.TeamLeadPhoto     = currentTeamLead.Photo;
            ViewBag.TeamLeadPhotoType = currentTeamLead.PhotoType;
            ViewBag.Seniority         = _dbEmployeeEnrollments.GetSeniority(id);
            var latestRealization = await _dbRealizations.GetLatestRealization(emp.EmployeeID);

            if (latestRealization == null)
            {
                ViewBag.CurrentProject = "No current project";
            }
            else
            {
                var selectCurrentProject = await _dbProjects.GetLatestProject(latestRealization.ProjectID);

                ViewBag.CurrentProject = selectCurrentProject == null ? "No current project" : selectCurrentProject.Name;
            }

            return(View());
        }
コード例 #2
0
        public async Task <JsonResult> SaveAbsenceAsync(Absence e)
        {
            //saving data for current user if ID is greater than 0 that means user wanted to update his absence
            // if not then new absence is being created
            ApplicationUser currentUser = await _dbUser.GetCurrentUser();

            var status = "none";

            try {
                if (e.AbsenceID > 0)
                {
                    _dbAbsence.Update(await _dbAbsence.UpdateMapDataAsync(e, currentUser.EmployeeID));
                    await _dbAbsence.SaveChangesAsync();

                    status = "edit";
                }
                else
                {
                    using (var dbContextTransaction = db.Database.BeginTransaction())
                    {
                        var absenceToSave = _dbAbsence.MapData(e, currentUser.EmployeeID);
                        _dbAbsence.Add(absenceToSave);
                        var absenceType = await _dbAbsenceType.GetById(absenceToSave.AbsenceTypeID);

                        Notification notify = new Notification();
                        notify.Message = $"{absenceToSave.Employee.FullName} is requesting absence {absenceType.Name.ToLower()} for period from {absenceToSave.Start.ToString("MMMM dd, yyyy")} to {absenceToSave.End.ToString("MMMM dd, yyyy")} {absenceToSave.EmployeeID} ";
                        if (absenceToSave.Employee.TeamLeadID > 0 && !absenceToSave.Employee.IsTeamLead)
                        {
                            notify.EmployeeID = _dbTeamLeads.GetById(absenceToSave.Employee.TeamLeadID).EmployeeID;
                        }
                        await _dbUser.UpdateAllWithIncrementedNotification(WorkPosition.HR, 1);

                        status = "save";
                        _dbNotify.Add(notify);
                        await _dbAbsence.SaveChangesAsync();

                        await _dbNotify.SaveChangesAsync();

                        dbContextTransaction.Commit();
                    }
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(new JsonResult {
                Data = new { status }
            });
        }
コード例 #3
0
        private async Task EditPreviousTeamLeadNotification(int?teamLeadID, string firstName, string lastName)
        {
            var employeeID   = _dbTeamLeads.GetById(teamLeadID).EmployeeID;
            var teamLeadName = await _dbEmployees.GetEmployeeByID(employeeID);

            var user = await _dbUser.GetUserByEmployeeID(employeeID);

            var notify = _dbNotify.MapData($"You({teamLeadName.FirstName} {teamLeadName.LastName}) are no longer team leader to {firstName} {lastName}", employeeID);

            user.CountNotifications = user.CountNotifications + 1;
            user.ReadNotifications  = false;
            _dbNotify.Add(notify);
            await _dbUser.UpdateAllWithIncrementedNotification(WorkPosition.HR, 1);

            await db.SaveChangesAsync();
        }