예제 #1
0
        public async Task <ResponseDto> CompanyById(int id)
        {
            var Company = await bll.CompanyById(id);

            result.data = _mapper.Map <CompanyDto>(Company);
            return(result);
        }
예제 #2
0
        public void SendCompanyEmail(int companyId)
        {
            var comp    = CompanyService.CompanyById(companyId);
            var profile = UserService.GetUserProfilesBy(comp.AdminId, FilterUserProfiles.ProfileId).FirstOrDefault();

            if (profile != null)
            {
                var param = new Dictionary <string, string>();
                param["USERNAME"] = profile.AspNetUsers.UserName;
                param["FNAME"]    = profile.Firstname;
                param["KEY"]      = profile.UserKey;
                param["URL"]      = comp.Domain;
                EmailModel.inst.Send(comp.Email, "EyeBeep invitation", "userInvite", param, null);
            }
        }
예제 #3
0
        /// <summary>
        /// Invokes for libraryView to set avaliable and assigned courses, list of departments and users
        /// </summary>
        /// <param name="companyId">id of selected company, 0 - if not used</param>
        /// <param name="departmentId">id of selected department, 0 if not used</param>
        /// <param name="userId">id of selected user, 0 if not used</param>
        /// <returns></returns>
        public JsonResult FilterCourses(int companyId, int departmentId, int userId)
        {
            LibraryFilter filter = new LibraryFilter();
            //getting avaliable courses
            var listavaliable = new List <MasterCourses>();
            //getting assigned courses
            var listassigned = new List <MasterCourses>();

            if (userId != 0)
            {
                listavaliable = CourseService.MasterCoursesAvaliableTo(userId, FilterIdType.UserId);
                listassigned  = CourseService.MasterCoursesAssignedTo(userId, FilterIdType.UserId);

                filter.assigned = listassigned.Select(item => new CoursesDto
                {
                    CourseId         = item.Id,
                    CoverUrl         = item.CoverUrl,
                    Name             = item.Name,
                    ShortDescription = item.ShortDescription,
                    Time             = item.CourseTime ?? 0,
                    Price            = item.Price ?? 0,
                    Released         = item.Released,
                    Exam             = item.Exam,
                    Exercises        = item.Exercises,
                    Diploma          = item.Diploma,
                    TrailerVideoUrl  = item.TrailerVideoUrl,
                    CourseStatus     = CourseService.GetCourseStatus(userId, FilterIdType.UserId, item.Id),
                    CategoryId       = item.CourseCategoryId,
                    CreatorId        = item.CreatorId,
                    OrderNum         = item.OrderNum
                }).OrderBy(i => i.OrderNum).ToList();
                filter.filterBy = "user";
            }
            else if (departmentId != 0)
            {
                listavaliable = CourseService.MasterCoursesAvaliableTo(departmentId, FilterIdType.DepartmentId);
                listassigned  = CourseService.MasterCoursesAssignedTo(departmentId, FilterIdType.DepartmentId);

                filter.assigned = listassigned.Select(item => new CoursesDto
                {
                    CourseId         = item.Id,
                    CoverUrl         = item.CoverUrl,
                    Name             = item.Name,
                    ShortDescription = item.ShortDescription,
                    Time             = item.CourseTime ?? 0,
                    Price            = item.Price ?? 0,
                    Released         = item.Released,
                    Exam             = item.Exam,
                    Exercises        = item.Exercises,
                    Diploma          = item.Diploma,
                    TrailerVideoUrl  = item.TrailerVideoUrl,
                    CourseStatus     = CourseService.GetCourseStatus(departmentId, FilterIdType.DepartmentId, item.Id),
                    CategoryId       = item.CourseCategoryId,
                    CreatorId        = item.CreatorId,
                    OrderNum         = item.OrderNum
                }).OrderBy(i => i.OrderNum).ToList();

                var dep = CompanyService.GetDepartment(departmentId);
                filter.users = dep.UserProfiles.Select(i => new UserSimple {
                    name = i.Firstname + " " + i.Lastname, id = i.Id
                }).ToList();
                filter.filterBy = "department";
            }
            else if (companyId != 0)
            {
                listavaliable   = CourseService.MasterCoursesAvaliableTo(companyId, FilterIdType.CompanyId);
                listassigned    = CourseService.MasterCoursesAssignedTo(companyId, FilterIdType.CompanyId);
                filter.assigned = listassigned.Select(item => new CoursesDto
                {
                    CourseId         = item.Id,
                    CoverUrl         = item.CoverUrl,
                    Name             = item.Name,
                    ShortDescription = item.ShortDescription,
                    Time             = item.CourseTime ?? 0,
                    Price            = item.Price ?? 0,
                    Released         = item.Released,
                    Exam             = item.Exam,
                    Exercises        = item.Exercises,
                    Diploma          = item.Diploma,
                    TrailerVideoUrl  = item.TrailerVideoUrl,
                    CourseStatus     = CourseService.GetCourseStatus(companyId, FilterIdType.CompanyId, item.Id),
                    CategoryId       = item.CourseCategoryId,
                    CreatorId        = item.CreatorId,
                    OrderNum         = item.OrderNum
                }).OrderBy(i => i.OrderNum).ToList();

                var company = CompanyService.CompanyById(companyId);
                filter.departments = company.Departments.Select(i => new DepartmentSimple {
                    id = i.Id, name = i.DepartmentName
                }).ToList();
                filter.users = company.UserProfiles.Select(i => new UserSimple {
                    name = i.Firstname + " " + i.Lastname, id = i.Id
                }).ToList();
                filter.filterBy = "company";
            }
            else
            {
                listavaliable = CourseService.GetAllMasterCourses();
            }

            filter.aviable = listavaliable.Select(item => new CoursesDto
            {
                CourseId         = item.Id,
                CoverUrl         = item.CoverUrl,
                Name             = item.Name,
                ShortDescription = item.ShortDescription,
                Time             = item.CourseTime ?? 0,
                Price            = item.Price ?? 0,
                Released         = item.Released,
                Exam             = item.Exam,
                Exercises        = item.Exercises,
                Diploma          = item.Diploma,
                TrailerVideoUrl  = item.TrailerVideoUrl,
                CourseStatus     = item.CourseStatus,
                CategoryId       = item.CourseCategoryId,
                CreatorId        = item.CreatorId,
                OrderNum         = item.OrderNum
            }).OrderBy(i => i.OrderNum).ToList();

            return(Json(filter, JsonRequestBehavior.AllowGet));
        }