public async Task <ExecutionResponse <DepartmentModel> > CreateDepartment(DepartmentModel model) { var oldDepartment = _departmentQueryRepo.GetAll().FirstOrDefault(x => x.Name.Trim().ToLower() == model.Name.Trim().ToLower()); if (oldDepartment != null) { throw new Exception("Department already exists"); } //save department info var department = new Department { Name = model.Name, CompanyId = CurrentCompanyId, Description = model.Description, CreateById = _httpContext.GetCurrentSSOUserId() }; await _departmentCommandRepo.InsertAsync(department); await _departmentCommandRepo.SaveChangesAsync(); return(new ExecutionResponse <DepartmentModel> { ResponseCode = ResponseCode.Ok, ResponseData = _mapper.Map <DepartmentModel>(department) }); }
public async Task <ExecutionResponse <CompanyModel> > CreateCompany(CompanyModel model) { var oldCompany = _companyQueryRepo.GetAll().FirstOrDefault(x => x.Name.Trim().ToLower() == model.Name.Trim().ToLower()); if (oldCompany != null) { throw new Exception("Company already exists"); } //save company info var company = new Company { Name = model.Name, Code = model.Code, CreateById = _httpContext.GetCurrentSSOUserId() }; await _companyCommandRepo.InsertAsync(company); await _companyCommandRepo.SaveChangesAsync(); return(new ExecutionResponse <CompanyModel> { ResponseCode = ResponseCode.Ok, ResponseData = _mapper.Map <CompanyModel>(company) }); }
public async Task <ExecutionResponse <MetricModel> > CreateMetric(UpdateMetricModel model) { var oldMetric = _metricQueryRepo.GetAll().FirstOrDefault(x => x.Name.Trim().ToLower() == model.Name.Trim().ToLower() && x.CompanyId == CurrentCompanyId); if (oldMetric != null) { throw new Exception("Metric already exists"); } //save metric info var metric = new Metric { Name = model.Name, DepartmentId = model.DepartmentId, Description = model.Description, CompanyId = CurrentCompanyId, CreateById = _httpContext.GetCurrentSSOUserId() }; await _metricCommandRepo.InsertAsync(metric); await _metricCommandRepo.SaveChangesAsync(); return(new ExecutionResponse <MetricModel> { ResponseCode = ResponseCode.Ok, ResponseData = _mapper.Map <MetricModel>(metric) }); }
public async Task <ExecutionResponse <UserModel[]> > GetUsersByRoleId(long roleId) { var userRoles = _userRoleQueryRepo.GetAll().Include(x => x.User).Where(x => x.RoleId == roleId) .Select(x => _mapper.Map <UserModel>(x.User)).ToArray(); userRoles = CurrentCompanyId == 0 ? userRoles : userRoles.Where(u => u.CompanyId == CurrentCompanyId).ToArray(); return(new ExecutionResponse <UserModel[]> { ResponseCode = ResponseCode.Ok, ResponseData = userRoles }); }
public ActionResult Index() { //var controller = ViewContext.RouteData.Values["Controller"]; //var action = ViewContext.RouteData.Values["Action"]; try { _log.LogInformation("Cubic ASP.Net Core Framework Config checked @ : {0}", DateTime.Now); _activityRepo.CreateActivityLog("In Framework setting checking if application portal has being configured", this.ControllerContext.ActionDescriptor.ControllerName, this.ControllerContext.ActionDescriptor.ActionName, 0, null); if (_applicationQuery.Count() >= 1) { if (_applicationQuery.GetAll().FirstOrDefault().HasAdminUserConfigured) { return(RedirectToAction("Login", "Account")); } else { return(RedirectToAction("Start", "FrameworkSetup", new { area = "Portal" })); } } else { return(RedirectToAction("Start", "FrameworkSetup", new { area = "Portal" })); } } catch (Exception ex) { _log.LogError(ex.Message); return(View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier })); } }
public ActionResult Index() { try { _log.InfoFormat("SleekSoft MVC Framework Config checked @ : {0}", DateTime.Now); _activityRepo.CreateActivityLog("In Framework setting checking if application portal has being configured", this.GetContollerName(), this.GetContollerName(), 0, null); if (_applicationQuery.Count() >= 1) { if (_applicationQuery.GetAll().FirstOrDefault().HasAdminUserConfigured) { return(RedirectToAction("Login", "Account")); } else { return(RedirectToAction("Start", "FrameworkSetup", new { area = "Portal" })); } } else { return(RedirectToAction("Start", "FrameworkSetup", new { area = "Portal" })); } } catch (Exception ex) { _log.Error(ex); return(View("Error")); } }
public ActionResult Index() { if (TempData["MESSAGE"] != null) { ViewBag.Msg = TempData["MESSAGE"] as string; } var model = _mapper.Map <List <PermissionViewModel> >(_permissionyQuery.GetAll()); return(View(model)); }
public IEnumerable <SelectListItem> GetPermission() { var types = _permissionyQuery.GetAll().Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.Name }); return(new SelectList(types, "Value", "Text")); }
public async Task <DataCollection <Logger> > Handle(GetLoggerByFilterQuery request, CancellationToken cancellationToken) { return(await _repository.GetAll(new FilterLogger { Page = request.Page, Take = request.Take, Start = request.Start, End = request.End }, cancellationToken)); }
public async Task <ExecutionResponse <VenueModel> > CreateVenue(VenueModel model) { var oldVenue = _venueQueryRepo.GetAll().FirstOrDefault(x => x.Name.Trim().ToLower() == model.Name.Trim().ToLower()); if (oldVenue != null) { throw new Exception("Venue already exists"); } //save venue info var venue = new Venue { Name = model.Name, CompanyId = CurrentCompanyId, Description = model.Description, CreateById = _httpContext.GetCurrentSSOUserId() }; await _venueCommandRepo.InsertAsync(venue); await _venueCommandRepo.SaveChangesAsync(); return(new ExecutionResponse <VenueModel> { ResponseCode = ResponseCode.Ok, ResponseData = _mapper.Map <VenueModel>(venue) }); }
public async Task <bool> ForgetPassword(string email) { if (string.IsNullOrEmpty(email)) { throw new BadRequestException("Email is required"); } if (!email.IsValidEmail()) { throw new BadRequestException("Email is not valid"); } var model = _userQueryRepo.GetAll().FirstOrDefault(x => x.Email.Trim().ToLower() == email.Trim().ToLower()); if (model == null) { throw new NotFoundException("User does not exist"); } var response = await _ssoService.ForgotPassword(email); if (response.ResponseCode == ResponseCode.Ok) { bool result = _emailService.ForgetPasswordEmail(response.ResponseData.Response.PasswordToken, email, $"{model.LastName} {model.FirstName}", model.SSOUserId); if (!result) { throw new BadRequestException("Forget password request failed"); } return(result); } else { return(false); } }
public async Task <ExecutionResponse <JobRoleModel> > CreateJobRole(UpdateJobRoleModel model) { var oldJobRole = _jobRoleQueryRepo.GetAll().FirstOrDefault(x => x.Name.Trim().ToLower() == model.Name.Trim().ToLower() && x.Department.CompanyId == CurrentCompanyId); if (oldJobRole != null) { throw new Exception("Job Role already exists"); } if (!_departmentQueryRepo.GetAll().Any(d => d.Id == model.DepartmentId && d.CompanyId == CurrentCompanyId)) { return new ExecutionResponse <JobRoleModel> { ResponseCode = ResponseCode.NotFound, Message = "Department does not exist" } } ; //save jobRole info var jobRole = new JobRole { Name = model.Name, DepartmentId = model.DepartmentId, Description = model.Description, CreateById = _httpContext.GetCurrentSSOUserId() }; await _jobRoleCommandRepo.InsertAsync(jobRole); await _jobRoleCommandRepo.SaveChangesAsync(); return(new ExecutionResponse <JobRoleModel> { ResponseCode = ResponseCode.Ok, ResponseData = _mapper.Map <JobRoleModel>(jobRole) }); }
public async Task <ExecutionResponse <object> > SetInterviewInterviewers(long[] interviewerIds, long interviewSessionId) { try { var interviewSession = _interviewSessionQueryRepo.GetAll().FirstOrDefault(x => x.Id == interviewSessionId && x.CompanyId == CurrentCompanyId); if (interviewSession == null) { throw new Exception("Interview session does not exist"); } var interviewInterviewers = _interviewSessionInterviewerQueryRepo.GetAll().Where(x => x.InterviewSessionId == interviewSessionId); //to add foreach (var id in interviewerIds) { if (!interviewInterviewers.Select(x => x.Id).ToArray().Contains(id)) { await _interviewSessionInterviewerCommandRepo.InsertAsync(new InterviewSessionInterviewer { InterviewSessionId = interviewSessionId, InterviewerId = id, CreateById = _httpContext.GetCurrentSSOUserId() }); } } //to remove foreach (var item in interviewInterviewers.ToList()) { if (!interviewerIds.Contains(item.Id)) { await _interviewSessionInterviewerCommandRepo.DeleteAsync(item); } } await _interviewSessionInterviewerCommandRepo.SaveChangesAsync(); return(new ExecutionResponse <object> { ResponseData = true, ResponseCode = ResponseCode.Ok }); } catch (Exception ex) { Log.Error(ex); return(new ExecutionResponse <object> { ResponseData = false, ResponseCode = ResponseCode.ServerException, Message = ex.Message }); } }
public async Task <ExecutionResponse <VenueModel[]> > GetAvailableVenue(DateTime startTime, DateTime endTime) { var unavailableVenueIds = _interviewSessionQueryRepo.GetAll().Where(x => (startTime >= x.StartTime && startTime <= x.EndTime) || (endTime >= x.StartTime && endTime <= x.EndTime)).Select(x => x.VenueId).ToArray(); var venues = _venueQueryRepo.GetAll(); venues = unavailableVenueIds.Count() > 0 ? venues.Where(v => !unavailableVenueIds.Contains(v.Id)) : venues; return(new ExecutionResponse <VenueModel[]> { ResponseCode = ResponseCode.Ok, ResponseData = _mapper.Map <VenueModel[]>(venues.ToArray()) }); }
public ActionResult Index() { if (TempData["MESSAGE"] != null) { ViewBag.Msg = TempData["MESSAGE"] as string; } var model = _permissionyQuery.GetAll().Select(e => new PermissionViewModel() { PermissionName = e.Name, PermissionId = e.Id, PermissionCode = e.Code }); return(View(model)); }
private bool LoadDefaultSettings() { var defaultSetting = _portalversionQuery.GetAll().Select(FrameworkDefaultSettingViewModel.EntityToModels).FirstOrDefault(); if (defaultSetting == null) { // ModelState.AddModelError("", "Unable to load default settings! Please check config file"); return(false); } if (_setupContract == null) { _setupContract = new FrameworkSetupViewModel(); } _setupContract.DefaultSetting = defaultSetting; return(true); }
private void LoadViewDataForDropDownList() { try { ViewData["ControllerList"] = GetControllerNames(); ViewData["UserList"] = _applicationUserQuery.GetAll().Select(x => new SelectListItem { Value = x.Id.ToString(), Text = x.FirstName + " " + x.MiddleName + " " + x.LastName }).AsEnumerable(); } catch (Exception ex) { _log.Error(ex); } }
private bool LoadDefaultSettings() { var portalversion = _portalversionQuery.GetAll().FirstOrDefault(); var portalversionmodel = _mapper.Map <FrameworkDefaultSettingViewModel>(portalversion); if (portalversionmodel == null) { // ModelState.AddModelError("", "Unable to load default settings! Please check config file"); return(false); } if (_setupContract == null) { _setupContract = new FrameworkSetupViewModel(); } _setupContract.DefaultSetting = portalversionmodel; return(true); }
// GET: APPPortal/EmailTemplate public ActionResult Index() { try { if (TempData["MESSAGE"] != null) { ViewBag.Msg = TempData["MESSAGE"] as string; } var model = _mapper.Map <List <EmailListViewModel> >(_EmailTemplateQuery.GetAll()); return(View(model)); } catch (Exception ex) { _log.LogError(ex.Message); return(View("Error")); } }
// GET: Portal/PortalUser public ActionResult Index() { try { _log.Info("<<< In Portal User Page >>>"); if (TempData["MESSAGE"] != null) { ViewBag.Msg = TempData["MESSAGE"] as string; } var usermodel = _applicationUserQuery.GetAll().Select(UserViewModel.EntityToModels).ToList(); return(View(usermodel)); } catch (Exception ex) { _log.Error(ex); return(View("Error")); } }
public async Task <ExecutionResponse <InterviewSessionModel> > GetInterviewSession(long Id) { var interviewSession = _interviewSessionQueryRepo.GetAll().FirstOrDefault(x => x.Id == Id && x.CompanyId == CurrentCompanyId); if (interviewSession == null) { return new ExecutionResponse <InterviewSessionModel> { ResponseCode = ResponseCode.NotFound, Message = "No record found" } } ; return(new ExecutionResponse <InterviewSessionModel> { ResponseCode = ResponseCode.Ok, ResponseData = _mapper.Map <InterviewSessionModel>(interviewSession) }); }
public async Task <ExecutionResponse <MetricModel> > UpdateMetric(UpdateMetricModel model) { var metric = _metricQueryRepo.GetAll().FirstOrDefault(x => x.Id == model.Id && x.CompanyId == CurrentCompanyId); if (metric == null) { return new ExecutionResponse <MetricModel> { ResponseCode = ResponseCode.NotFound, Message = "No record found" } } ; if (!_departmentQueryRepo.GetAll().Any(d => d.Id == model.DepartmentId && d.CompanyId == CurrentCompanyId)) { return new ExecutionResponse <MetricModel> { ResponseCode = ResponseCode.NotFound, Message = "Department does not exist" } } ; //update metric record in db metric.Name = model.Name; metric.Description = model.Description; metric.DepartmentId = model.DepartmentId; await _metricCommandRepo.UpdateAsync(metric); await _metricCommandRepo.SaveChangesAsync(); return(new ExecutionResponse <MetricModel> { ResponseCode = ResponseCode.Ok, ResponseData = _mapper.Map <MetricModel>(metric) }); }
// GET: APPPortal/EmailTemplate public ActionResult Index() { try { if (TempData["MESSAGE"] != null) { ViewBag.Msg = TempData["MESSAGE"] as string; } var model = _EmailTemplateQuery.GetAll().Select(e => new EmailViewModel() { EmailID = e.Id, EmailSubject = e.Name, EmailCode = e.Code }); return(View(model)); } catch (Exception ex) { _log.Info(ex); return(View("Error")); } }
public JsonResult GetEvents(ScheduleViewModel scheduleVm) { DateTime sdate = DateTime.Now; DateTime edate = DateTime.Now; DateTime.TryParse(scheduleVm.StartDate, out sdate); DateTime.TryParse(scheduleVm.EndDate, out edate); if (sdate == DateTime.MinValue) { sdate = DateTime.Now; } if (edate == DateTime.MinValue) { edate = ExtentionUtility.GetDateValue(DateTime.Now.ToString("yyyy-MM-") + DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month).ToString()); } var model = new List <ScheduleViewModel>(); List <Event> eventmodel = _EventQuery.GetAll().ToList(); if (eventmodel.Any()) { foreach (Event e in eventmodel) { model.Add(new ScheduleViewModel() { Id = e.Id, start = e.StartDate, //eventVmodel.StartDate, end = e.EndDate, //eventVmodel.EndDate, title = "Event: " + e.EventName + "\nVenue: " + e.Venue + "\n Description : " + e.EventDescription }); } } return(Json(model, JsonRequestBehavior.AllowGet)); }
public IActionResult Get([FromQuery] string sort = null, [FromQuery] string order = "asc") { var result = _query.GetAll(sort, order).ToList(); return(Ok(result)); }
public async Task <ExecutionResponse <UserModel> > AddUserRole(UserRoleModel model) { var role = _roleQueryRepo.GetAll().FirstOrDefault(f => f.Id == model.RoleId); if (role == null) { return(new ExecutionResponse <UserModel> { ResponseCode = ResponseCode.NotFound, Message = "Role does not exist" }); } if (CurrentCompanyId == 0 && role.RoleName != "CompanyAdmin") { throw new Exception($"You cannot add role '{role.RoleName}' to a user"); } var user = _userQueryRepo.GetAll().FirstOrDefault(f => f.Id == model.UserId); if (user == null || (CurrentCompanyId != 0 && user.CompanyId != CurrentCompanyId)) { return(new ExecutionResponse <UserModel> { ResponseCode = ResponseCode.NotFound, Message = "User does not exist" }); } if (!user.UserRoles.Any(u => u.RoleId == role.Id)) { var result = await _ssoService.AddRemoveClaims(new UserClaimModel { Claims = new List <SSOClaim> { new SSOClaim("role", role.RoleName) }, UserId = user.SSOUserId }, ClaimAction.Add); if (result.ResponseCode == ResponseCode.Ok) { await _userRoleCommandRepo.InsertAsync(new UserRole { RoleId = role.Id, UserId = user.Id }); await _userRoleCommandRepo.SaveChangesAsync(); return(await GetUser(model.UserId)); } else { return(new ExecutionResponse <UserModel> { ResponseCode = ResponseCode.ServerException, Message = result.Message }); } } else { return(new ExecutionResponse <UserModel> { ResponseCode = ResponseCode.ServerException, Message = "User is already attached to specified role" }); } }
public IActionResult Get() { var result = _query.GetAll().ToList(); return(Ok(result)); }
public async Task <ExecutionResponse <UserModel> > CreateUser(CreateUserModel model) { if (_userQueryRepo.GetAll().Any(u => u.Email.Trim().ToLower() == model.Email.Trim().ToLower())) { return new ExecutionResponse <UserModel> { ResponseCode = ResponseCode.ServerException, Message = "User with specified email already exists" } } ; var role = _roleQueryRepo.GetAll().FirstOrDefault(x => x.Id == model.RoleId); if (role == null) { throw new Exception("Invalid Role"); } if (CurrentCompanyId == 0 && role.RoleName != "CompanyAdmin") { throw new Exception($"You cannot create a user with role '{role.RoleName}'"); } var company = _companyQueryRepo.GetAll().FirstOrDefault(x => x.Id == model.CompanyId); if (company == null) { throw new Exception("Company does not exist"); } var registerReponse = await _ssoService.Register(new SSOUserDto { Claims = new List <SSOClaim> { new SSOClaim("role", GetSSORole(role.RoleName)), new SSOClaim("role", role.RoleName) }, ConfirmEmail = false, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = string.IsNullOrEmpty(model.PhoneNumber) ? "08111111111" : model.PhoneNumber, UserName = model.UserName, Password = model.Password }); if (registerReponse.ResponseCode != ResponseCode.Ok) { return new ExecutionResponse <UserModel> { ResponseCode = ResponseCode.ServerException, Message = registerReponse.Message } } ; //user registered on sso //trigger reset password //save user info var user = new User { Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, PhoneNumber = string.IsNullOrEmpty(model.PhoneNumber) ? "08111111111" : model.PhoneNumber, UserName = model.UserName, CompanyId = CurrentCompanyId == 0 ? model.CompanyId : CurrentCompanyId, EmailConfirmed = false, CreateById = CurrentUserId, SSOUserId = registerReponse.ResponseData.UserId }; await _userCommandRepo.InsertAsync(user); await _userCommandRepo.SaveChangesAsync(); //assign role to user await _userRoleCommandRepo.InsertAsync(new UserRole { RoleId = role.Id, UserId = user.Id, CreateById = CurrentUserId }); await _userRoleCommandRepo.SaveChangesAsync(); //send email confirmation mail _emailService.EmailConfirmation(registerReponse.ResponseData.EmailConfirmationToken, model.Email, $"{model.FirstName} {model.LastName}", registerReponse.ResponseData.UserId); return(new ExecutionResponse <UserModel> { ResponseCode = ResponseCode.Ok, ResponseData = _mapper.Map <UserModel>(user) }); }
public async Task <RoleModel[]> GetAll() { var roles = _roleQueryRepo.GetAll().ToArray(); return(_mapper.Map <RoleModel[]>(roles)); }
public ActionResult FrameworkSetting(FrameworkSetupViewModel model, string nextButton, string backButton) { ModelState.Clear(); _activityRepo.CreateActivityLog("In Framework setting currentconfig", this.ControllerContext.ActionDescriptor.ControllerName, this.ControllerContext.ActionDescriptor.ActionName, 0, null); if (backButton != null) { return(RedirectToAction("CurrentConfig")); } if (nextButton != null) { if (!ModelState.IsValid) { return(View(_setupContract)); } if (string.IsNullOrEmpty(model.PortalSetting.PortalTitle)) { ModelState.AddModelError("", "Portal title is required"); return(View(_setupContract)); } var app = new Application { ApplicationName = model.PortalSetting.PortalTitle, Description = model.PortalSetting.PortalDescription, TermsAndConditions = model.PortalSetting.TermsAndConditionPath, HasAdminUserConfigured = false }; if (_applicationQuery.GetAll().Any()) { Application datamodel = _applicationQuery.GetAll().FirstOrDefault(); app.Id = datamodel.Id; datamodel.ApplicationName = app.ApplicationName; datamodel.Description = app.Description; datamodel.TermsAndConditions = app.TermsAndConditions; _applicationCommand.Update(datamodel); } else { _applicationCommand.Insert(app); } _applicationCommand.SaveChanges(); if (app.Id >= 1) { _activityRepo.CreateActivityLog("creating Framework application data", this.ControllerContext.ActionDescriptor.ControllerName, this.ControllerContext.ActionDescriptor.ActionName, 0, app); return(RedirectToAction("FramewokAdmin")); } ModelState.AddModelError("", "Unable to save framework settings due to internal error! Please try again later"); return(View(_setupContract)); } var application = _applicationQuery.GetAll().FirstOrDefault(); var portalInfo = _mapper.Map <PortalSettingViewModel>(application); if (portalInfo == null) { // ModelState.AddModelError("", "Unable to initialize portal information due to internal error! Please try again later"); return(View(_setupContract)); } _setupContract.PortalSetting = portalInfo; return(View(_setupContract)); //add settings to DB }