コード例 #1
0
        /*
         * This Method return list of all the Departments in DB.
         */
        public IEnumerable <DepartmentDetailsDto> GetAllDepartment()
        {
            List <DepartmentDetailsDto> DeptList = new List <DepartmentDetailsDto>();

            try
            {
                var allDept = Context.DepartmentDetails.ToList();
                foreach (DepartmentDetails dept in allDept)
                {
                    DepartmentDetailsDto deptDto = new DepartmentDetailsDto();
                    deptDto.DepartmentId          = dept.DepartmentId;
                    deptDto.DepartmentName        = dept.DepartmentName;
                    deptDto.DepartmentHeadName    = dept.DepartmentHeadName;
                    deptDto.DepartmentDiscription = dept.DepartmentDiscription;

                    DeptList.Add(deptDto);
                }
                return(DeptList);
            }
            catch (SqlException expSql)
            {
                throw expSql;
            }
            catch (NullReferenceException expNull)
            {
                throw expNull;
            }
        }
コード例 #2
0
        public async Task <int> InsertAsync(Department department)
        {
            object[] primaryKeyValues = await _repository.InsertAsync(department);

            int departmentId = (int)primaryKeyValues[0];

            department.Id = departmentId;

            // Add item to the cache list
            string departmentCacheKey = DepartmentCacheKeys.GetKey(department.Id);
            await _distributedCache.SetAsync(departmentCacheKey, department);

            string departmentDetailsCacheKey = DepartmentCacheKeys.GetDetailsKey(department.Id);

            DepartmentDetailsDto departmentDetailsDto = new DepartmentDetailsDto()
            {
                DepartmentId      = department.Id,
                DepartmentName    = department.Name,
                Description       = department.Description,
                IsActive          = department.IsActive,
                CreatedAtUtc      = department.CreatedAtUtc,
                LastModifiedAtUtc = department.LastModifiedAtUtc
            };
            await _distributedCache.SetAsync(departmentDetailsCacheKey, departmentDetailsDto);

            string departmentListKey = DepartmentCacheKeys.ListKey;
            await _distributedCache.AddToListAsync(departmentListKey, department, d => d.Name);

            string departmentSelectListKey = DepartmentCacheKeys.SelectListKey;
            await _distributedCache.AddToListAsync(departmentSelectListKey, department, d => d.Name);

            return(departmentId);
        }
コード例 #3
0
        public async Task UpdateAsync(Department department)
        {
            await _repository.UpdateAsync(department);

            // Update item in cache
            string departmentCacheKey = DepartmentCacheKeys.GetKey(department.Id);
            await _distributedCache.SetAsync <Department>(departmentCacheKey, department);

            string departmentDetailsCacheKey = DepartmentCacheKeys.GetDetailsKey(department.Id);

            DepartmentDetailsDto departmentDetailsDto = new DepartmentDetailsDto()
            {
                DepartmentId      = department.Id,
                DepartmentName    = department.Name,
                Description       = department.Description,
                IsActive          = department.IsActive,
                CreatedAtUtc      = department.CreatedAtUtc,
                LastModifiedAtUtc = department.LastModifiedAtUtc
            };

            await _distributedCache.SetAsync(departmentDetailsCacheKey, departmentDetailsDto);

            string departmentListKey = DepartmentCacheKeys.ListKey;
            await _distributedCache.UpdateInListAsync <Department>(departmentListKey, d => d.Id == department.Id, department);

            string departmenSelecttListKey = DepartmentCacheKeys.SelectListKey;
            await _distributedCache.UpdateInListAsync(departmenSelecttListKey, d => d.Id == department.Id, department);
        }
コード例 #4
0
        public async Task <DepartmentDetailsDto> FindDepartmentById(int departmentId)
        {
            var entity = (await _departmentRepository.Find(dept => dept.Id == departmentId)).FirstOrDefault();

            if (entity == null)
            {
                throw new Exception("Department not found");
            }

            var model = new DepartmentDetailsDto()
            {
                Id   = entity.Id,
                Name = entity.Name
            };

            var employees = await _employeeRepository.Find(emp => emp.DepartmentId == departmentId);

            model.EmployeeList = employees.Select(emp => new EmployeeSearchItemDto()
            {
                FullName = emp.LastName + ", " + emp.FirstName,
                Title    = emp.Title
            }).ToList();

            return(model);
        }
コード例 #5
0
        public async Task <DepartmentDetailsDto> GetByIdAsync(int departmentId)
        {
            departmentId.ThrowIfNotPositive(nameof(departmentId));

            DepartmentDetailsDto departmentDetailsDto = await _departmentCacheRepository.GetDetailsByIdAsync(departmentId);

            return(departmentDetailsDto);
        }
コード例 #6
0
        public async Task <DepartmentDetailsModel> GetDepartment(int departmentId)
        {
            DepartmentDetailsDto departmentDetailsDto = await _departmentService.GetDepartmentAsync(departmentId);

            DepartmentDetailsModel departmentDetailsModel = _mapper.Map <DepartmentDetailsModel>(departmentDetailsDto);

            return(departmentDetailsModel);
        }
コード例 #7
0
ファイル: CompanyService.svc.cs プロジェクト: nietcdf/101repo
        public decimal CutDept(DepartmentDetailsDto dept)
        {
            var department = Company.AllDepartments.Where(d => d.Id == dept.Id).First();

            department.Cut();

            return(department.Total);
        }
コード例 #8
0
        public async Task UpdateDepartmentRecord(DepartmentDetailsDto department)
        {
            var entity = new Department()
            {
                UpdatedDate = DateTime.Now,
                Name        = department.Name,
            };

            await _departmentRepository.Update(entity);
        }
コード例 #9
0
        public async Task <int> CreateDepartment(DepartmentDetailsDto department)
        {
            var entity = new Department()
            {
                CreatedDate = DateTime.Now,
                Name        = department.Name,
            };

            var id = await _departmentRepository.Add(entity);

            return(id);
        }
コード例 #10
0
        public ActionResult Details(DepartmentDetailsDto model)
        {
            try
            {
                // TODO: Add insert logic here

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
コード例 #11
0
        public async Task <ActionResult <DepartmentDetailsDto> > GetDepartment(int departmentId)
        {
            try
            {
                DepartmentDetailsDto departmentDetailsDto = await _departmentService.GetByIdAsync(departmentId);

                return(departmentDetailsDto);
            }
            catch (Exception exception)
            {
                await _exceptionLogger.LogAsync(exception);

                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
コード例 #12
0
        public async Task <DepartmentDetailsDto> GetDepartmentAsync(int departmentId)
        {
            DepartmentDetailsDto departmentDetailsDto = await _unitOfWork.Repository <Department>().Entities.Where(d => d.DepartmentId == departmentId)
                                                        .Select(d => new DepartmentDetailsDto
            {
                DepartmentId      = d.DepartmentId,
                DepartmentName    = d.DepartmentName,
                Description       = d.Description,
                IsActive          = d.IsActive,
                CreatedAtUtc      = d.CreatedAtUtc,
                LastModifiedAtUtc = d.LastModifiedAtUtc
            }).FirstOrDefaultAsync();

            return(departmentDetailsDto);
        }
コード例 #13
0
ファイル: CompanyService.svc.cs プロジェクト: nietcdf/101repo
        public DepartmentDetailsDto GetDepartmentDetails(Guid id)
        {
            var dept = CompanyRepository.Find <Department>(d => d.Id == id).First();

            var dto = new DepartmentDetailsDto()
            {
                Id      = dept.Id,
                Name    = dept.Name,
                Manager = new EmployeeDto()
                {
                    Address = dept.Manager.Person.Address,
                    Id      = dept.Manager.Id,
                    Name    = dept.Manager.Person.Name,
                    Salary  = dept.Manager.Salary
                },
                Total = dept.Total,
            };

            return(dto);
        }
コード例 #14
0
        public async Task <DepartmentDetailsDto> GetDetailsByIdAsync(int departmentId)
        {
            string cacheKey = DepartmentCacheKeys.GetDetailsKey(departmentId);
            DepartmentDetailsDto department = await _distributedCache.GetAsync <DepartmentDetailsDto>(cacheKey);

            if (department == null)
            {
                Expression <Func <Department, DepartmentDetailsDto> > selectExp = d => new DepartmentDetailsDto
                {
                    DepartmentId      = d.Id,
                    DepartmentName    = d.Name,
                    Description       = d.Description,
                    IsActive          = d.IsActive,
                    CreatedAtUtc      = d.CreatedAtUtc,
                    LastModifiedAtUtc = d.LastModifiedAtUtc
                };

                department = await _repository.GetByIdAsync(departmentId, selectExp);

                await _distributedCache.SetAsync <DepartmentDetailsDto>(cacheKey, department);
            }

            return(department);
        }
コード例 #15
0
        public async Task <IActionResult> Create(DepartmentDetailsDto collection)
        {
            await _mendelCoreServices.CreateDepartment(collection);

            return(RedirectToAction(nameof(Index)));
        }
コード例 #16
0
        /*
         * This method returns only the Employee Details of given employeeID
         */
        public EmployeeDto EmployeeDetails(int emplId)
        {
            try
            {
                var Employee = Context.Employees
                               .Include(emp => emp.ContactDetails)
                               .Include(emp => emp.DepartmentDetails)
                               .Include(emp => emp.EmployeeBiography)
                               .Include(emp => emp.employeeRoles)
                               .Include(emp => emp.TeamDetails)
                               .Include(emp => emp.EmployeeBiography)
                               .FirstOrDefault(emp => emp.EmployeeId == emplId);
                var skills = Context.EmployeeSkills
                             .Include(s => s.skills)
                             .Where(s => s.EmployeeId == Employee.EmployeeId)
                             .Select(s => new EmployeeSkillsDto
                {
                    SkillName  = s.skills.SkillName,
                    SkillLevel = s.SkillLevel,
                    EmployeeId = s.EmployeeId,
                    SkillId    = s.SkillId
                }).ToList();

                EmployeeDto          empl    = new EmployeeDto();
                RolesDto             role    = new RolesDto();
                DepartmentDetailsDto depart  = new DepartmentDetailsDto();
                TeamDetailDto        team    = new TeamDetailDto();
                ContactDto           contact = new ContactDto();
                BioGraphyDto         bio     = new BioGraphyDto();

                empl.FirstName   = Employee.FirstName;
                empl.LastName    = Employee.LastName;
                empl.EmployeeId  = Employee.EmployeeId;
                empl.Dob         = Employee.Dob;
                empl.JoiningDate = Employee.JoiningDate;
                empl.EmailId     = Employee.EmailID;
                empl.PhotoUrl    = Employee.EmployeePhotoURL;
                empl.SPOC        = Employee.SPOC;
                role.RoleName    = Employee.employeeRoles.RoleName;
                empl.Role        = role;

                depart.DepartmentName = Employee.DepartmentDetails.DepartmentName;
                empl.Departmnent      = depart;


                team.TeamName = Employee.TeamDetails.TeamName;
                team.LeadName = Employee.TeamDetails.TeamLeadName;
                empl.Team     = team;

                contact.Address        = Employee.ContactDetails.Address;
                contact.MobileOffice   = Employee.ContactDetails.MobNumberOff;
                contact.MobilePersonal = Employee.ContactDetails.MobNumberPersonal;
                contact.SkypeId        = Employee.ContactDetails.SkypeID;
                contact.SlackId        = Employee.ContactDetails.SlackID;
                contact.FBLink         = Employee.ContactDetails.FBLink;
                contact.TwitterLink    = Employee.ContactDetails.TwitterLink;
                contact.GitHubLink     = Employee.ContactDetails.GitHubLink;
                contact.LinkdinLink    = Employee.ContactDetails.linkdinLink;
                empl.ContactDetail     = contact;

                bio.About     = Employee.EmployeeBiography.About;
                bio.Hobbies   = Employee.EmployeeBiography.Hobbies;
                bio.Interests = Employee.EmployeeBiography.Interests;
                empl.Bio      = bio;

                foreach (EmployeeSkillsDto empSkill in skills)
                {
                    empl.EmployeeSkills.Add(empSkill);
                }

                return(empl);
            }
            catch (SqlException exSql)
            {
                throw exSql;
            }
            catch (NullReferenceException expNull)
            {
                throw expNull;
            }
        }