public Object AddGroupUser([FromBody] WebGroupUser webGroupUser, long id) { var bodyResponse = new WebJsonResponse(); try { var curator = _authorizationRepository.GetUserByCredentials(WebRequestHeaders.GetAuthorizationToken(this)); if (curator == null) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } var groupUser = AutoMapper.Mapper.Map<WebGroupUser, GroupUser>(webGroupUser); var addedGroupUser = _groupRepository.AddGroupUser(groupUser, id, curator); bodyResponse.Data = AutoMapper.Mapper.Map<GroupUser, WebGroupUser>(addedGroupUser); bodyResponse.Status = true; } catch(UnauthorizedException) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } catch (Exception exception) { bodyResponse.Error = exception.Message; } return bodyResponse; }
public Object CreateCuratorMethodicsGroup(long curatorId, [FromBody] WebCuratorMethodicsGroup webMethodicsGroup) { WebJsonResponse response = new WebJsonResponse(); try { Guid token = WebRequestHeaders.GetAuthorizationToken(this); //if (!ClientRepository.CheckAuthorization(token, curatorId, false)) //{ // return new HttpResponseMessage(HttpStatusCode.Unauthorized); //} PersonContent personAuth = ClientRepository.GetPerson(token); if (!ClientRepository.CheckClientRights(personAuth.Id, curatorId)) { return new HttpResponseMessage(HttpStatusCode.MethodNotAllowed); } response.Data = Mapper.Map<CuratorMethodicsGroup, WebCuratorMethodicsGroup>(_curatorRepository.CreateCuratorMethodicsGroup(curatorId, Mapper.Map<WebCuratorMethodicsGroup, CuratorMethodicsGroup>(webMethodicsGroup))); response.Status = true; } catch (UnauthorizedException) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public Object GetConclusions(long conclusionId) { WebJsonResponse response = new WebJsonResponse(); try { Guid token = WebRequestHeaders.GetAuthorizationToken(this); RegistrationContent user = ClientRepository.GetUser(token); if (!ClientRepository.CheckAuthorization(token, user.PersonId)) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } response.Data = _conclusionRepository.GetConclusion(conclusionId) ?? new object(); response.Status = true; } catch (UnauthorizedException) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public Object DeleteSurveysResult(long surveysResultId) { WebJsonResponse response = new WebJsonResponse(); try { Guid token = WebRequestHeaders.GetAuthorizationToken(this); PersonContent person = ClientRepository.GetPerson(token); if (!ClientRepository.CheckSurveysRights(person.Id, surveysResultId)) { return new HttpResponseMessage(HttpStatusCode.MethodNotAllowed); } _surveysResultRepository.DeleteSurveysResult(surveysResultId); response.Data = new object(); response.Status = true; } catch (UnauthorizedException) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public WebJsonResponse GetRoles() { var bodyResponse = new WebJsonResponse(); try { bodyResponse.Data = AutoMapper.Mapper.Map<List<Role>, List<WebRole>>(_roleRepository.GetRoles()); bodyResponse.Status = true; } catch (Exception exception) { bodyResponse.Error = exception.Message; } return bodyResponse; }
public WebJsonResponse GetConclusionTypes() { WebJsonResponse response = new WebJsonResponse(); try { response.Data = _conclusionRepository.GetConclusionTypes(); response.Status = true; } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public WebJsonResponse Register([FromBody] RegistrationContent registratedUser) { WebJsonResponse response = new WebJsonResponse(); try { response.Data = _clientRepository.Register(registratedUser); response.Status = true; } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public WebJsonResponse AuthorizePerson([FromBody] PersonContent authorizedPerson) { WebJsonResponse response = new WebJsonResponse(); try { response.Data = _clientRepository.AuthorizePerson(authorizedPerson.AccessKey); response.Status = true; } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public WebJsonResponse GetPersonContent(long personId) { WebJsonResponse response = new WebJsonResponse(); try { response.Data = _clientRepository.GetPersonContent(personId) ?? new object(); response.Status = true; } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public WebJsonResponse DeleteResultItems(Guid id) { var bodyResponse = new WebJsonResponse(); try { resultRepository.DeleteResultItems(id); bodyResponse.Status = true; bodyResponse.Data = new object(); } catch (Exception exception) { bodyResponse.Error = exception.Message; } return bodyResponse; }
public WebJsonResponse GetPackageTests(int packageId) { WebJsonResponse response = new WebJsonResponse(); try { response.Data = Mapper.Map<List<Test>, List<WebTest>>(_packageRepository.GetPackgeTests(packageId)); response.Status = true; } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public WebJsonResponse GetQuestions() { var bodyResponse = new WebJsonResponse(); try { bodyResponse.Data = AutoMapper.Mapper.Map<List<LusherPairScenarioItem>, List<WebLusherScenarioItem>>(_lusherPairRepository.GetAllQuestions()); bodyResponse.Status = true; } catch (Exception exception) { bodyResponse.Error = exception.Message; } return bodyResponse; }
public WebJsonResponse CreateProfile(Guid resultId) { var bodyResponse = new WebJsonResponse(); try { // TEST KEttel //var answers2 = //"1 1 3 1 3 1 3 3 1 1 3 2 1 3 1 1 3 3 2 2 3 1 3 1 3 3 3 2 1 1 1 3 1 2 3 1 3 2 2 1 1 3 1 2 3 3 2 2 3 1 3 1 2 2 1 2 2 2 3 1 2 3 1 3 3 1 1 1 1 1 3 3 1 2 1 3 3 3 3 3 3 3 1 3 3 2 3 1 1 3 3 2 3 3 3 2 2 2 3 1 1 2 2 3 1 1 2 1 2 1 1 1 1 1 3 3 1 2 1 1 3 3 3 3 2 2 3 2 3 1 1 2 3 3 1 1 2 1 3 2 1 3 3 3 3 1 3 3 2 3 1 1 3 3 1 3 3 2 1 3 2 2 1 1 2 3 1 2 3 3 2 3 1 2 3 1 1 2 2 1 3 2 1 3 1 1 1 "; //// Female 0 - 18 //var user = new OldUser { Gender = false, BirthDate = DateTime.Now.AddYears(-13) }; //KettelMethod kettel = new KettelMethod(user, answers2); //kettel.CreateProfile(); //var output = new KettelOutput(); //bodyResponse.Data = output.CreateOutputJson(kettel); // TEST SelfApprs //var sfAnswers = "10 6 6 3 7 3 1 1 1 8 3 3 4 10 5 10 "; //SelfAppraisalMethod sfAppr = new SelfAppraisalMethod(sfAnswers); //sfAppr.CreateProfile(); //var sfOutput = new SelfAppraisalOutput(); //bodyResponse.Data = sfOutput.CreateOutputJson(sfAppr); //TEST Sondi //var snAnswers = // //"1 2 3 4 7 6 8 5 2 1 4 3 6 5 8 7 1 2 4 3 5 6 8 7 1 2 4 3 5 6 8 7 2 1 3 4 6 5 7 8 2 1 3 4 6 5 8 7 "; // "1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 "; //SondiMethod sondi = new SondiMethod(snAnswers); //sondi.Initialize(); //sondi.ConvertAnswersString(); //sondi.CreateProfile(); //SondiOutput snOutput = new SondiOutput(); //bodyResponse.Data = snOutput.CreateOutputJson(sondi); //bodyResponse.Data = AutoMapper.Mapper.Map<Profile, WebProfile>(_profileRepository.CreateProfile(resultId)); bodyResponse.Data = _profileRepository.GenerateProfile(resultId); bodyResponse.Status = true; } catch (Exception exception) { //bodyResponse.Error = String.Format("Message: {0}\nStackTrace: {1}\nInner exception: {2}" ,exception.Message, exception.StackTrace, exception.InnerException); bodyResponse.Error = exception.Message; } return bodyResponse; }
public Object CreateSurveysResult(long personId, [FromBody] WebSurveysResult webSurveysResult) { WebJsonResponse response = new WebJsonResponse(); try { Guid token = WebRequestHeaders.GetAuthorizationToken(this); PersonContent person = ClientRepository.GetPerson(token); if (!ClientRepository.CheckPersonRights(person.Id, personId)) { return new HttpResponseMessage(HttpStatusCode.MethodNotAllowed); } //if (!ClientRepository.CheckAuthorization(token, personId)) //{ // return new HttpResponseMessage(HttpStatusCode.Unauthorized); //} // Manual mapping SurveysResult surveysResult = new SurveysResult() { MethodsType = webSurveysResult.MethodsType, MethodsId = webSurveysResult.MethodsId }; if (webSurveysResult.ParentId.HasValue) { surveysResult.Parent = new SurveysResult() {Id = webSurveysResult.ParentId.Value}; } response.Data = Mapper.Map<SurveysResult, WebSurveysResult>(_surveysResultRepository.CreateSurveysResult(personId, surveysResult)); response.Status = true; } catch (UnauthorizedException) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public WebJsonResponse GetPersonResultsList(int personId) { var bodyResponse = new WebJsonResponse(); try { bodyResponse.Data = AutoMapper.Mapper.Map<ICollection<Result>, ICollection<WebResultOut>>( resultRepository.GetResultsByPerson(personId)); bodyResponse.Status = true; } catch (Exception exception) { bodyResponse.Error = exception.Message; } return bodyResponse; }
public WebJsonResponse GetServicePrice(int id) { WebJsonResponse response = new WebJsonResponse(); try { response.Data = _serviceRepository.GetServicePrice(id); if (response.Data == null) { response.Data = new object(); } response.Status = true; } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public WebJsonResponse GetServices(String methodsType, int methodsId) { WebJsonResponse response = new WebJsonResponse(); try { response.Data = AutoMapper.Mapper.Map<List<Service>, List<WebService>>(_serviceRepository.GetServices(methodsType, methodsId)); if (response.Data == null) { response.Data = new object(); } response.Status = true; } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public Object GetImage(String image) { try { var content = new StreamContent(_kotRepository.GetKotImage(image)); var response = new HttpResponseMessage(); response.Content = content; response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpg"); return response; } catch (Exception exception) { var bodyResponse = new WebJsonResponse(); bodyResponse.Error = exception.Message; return bodyResponse; } }
public WebJsonResponse GetQuestions() { var bodyResponse = new WebJsonResponse(); try { var listWebQuestions = AutoMapper.Mapper.Map<List<AccentQuestion>, List<WebAccentQuestion>>((List<AccentQuestion>) _acceptRepository.GetAllQuestions()); var listWebAnswers = AutoMapper.Mapper.Map<List<AccentAnswer>, List<WebAccentAnswer>>((List<AccentAnswer>)_acceptRepository.GetAllAnswers()); foreach (var question in listWebQuestions) { question.Answers = listWebAnswers; } bodyResponse.Data = listWebQuestions; bodyResponse.Status = true; } catch (Exception exception) { bodyResponse.Error = exception.Message; } return bodyResponse; }
public WebJsonResponse WriteTestResults([FromBody] List<WebConcreteQuestion> webResultItems, int PersonId, int TestId) { var bodyResponse = new WebJsonResponse(); try { var result = resultRepository.SaveResults(PersonId, TestId, webResultItems); // Save results in db table ShellResults for future import in offline Consul db resultRepository.SaveResultsForImport(result, webResultItems); bodyResponse.Status = true; bodyResponse.Data = AutoMapper.Mapper.Map<Result, WebResultOut>(result); } catch (Exception exception) { bodyResponse.Error = exception.Message; } return bodyResponse; }
public Object OrderConclusion(long conclusionId, [FromBody] WebConclusion webConclusion) { WebJsonResponse response = new WebJsonResponse(); try { Guid token = WebRequestHeaders.GetAuthorizationToken(this); PersonContent person = ClientRepository.GetPerson(token); SurveysConclusionItem conclusion = _conclusionRepository.GetConclusion(conclusionId); if (!ClientRepository.CheckSurveysRights(person.Id, conclusion.SurveysResultId)) { return new HttpResponseMessage(HttpStatusCode.MethodNotAllowed); } //RegistrationContent user = ClientRepository.GetUser(token); //if (!ClientRepository.CheckAuthorization(token, user.PersonId)) //{ // return new HttpResponseMessage(HttpStatusCode.Unauthorized); //} _conclusionRepository.OrderConclusion(conclusionId, webConclusion.Ordered); response.Data = new object(); response.Status = true; } catch (UnauthorizedException) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public Object SetSurveysAnswers(long surveysResultId, [FromBody] List<SurveysAnswerContent> surveysAnswerContents) { WebJsonResponse response = new WebJsonResponse(); try { Guid token = WebRequestHeaders.GetAuthorizationToken(this); Person authorizedPerson = _surveysResultRepository.GetPerson(surveysResultId); if (!ClientRepository.CheckAuthorization(token, authorizedPerson.Id)) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } // Set answers _lusherPairRepository.SetLusherPairSpecialAnswers(surveysResultId, surveysAnswerContents); // Set isCompleted to Survey _surveysResultRepository.CompleteSurveyResult(surveysResultId); // Complete parent survey if it exists and all child is completed _surveysResultRepository.CompleteParentPackageSurvey(surveysResultId); _surveysResultRepository.CompleteParentCuratorSurvey(surveysResultId); response.Data = new object(); response.Status = true; } catch (UnauthorizedException) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public WebJsonResponse GetQuestions() { var bodyResponse = new WebJsonResponse(); try { var listWebQuestions = AutoMapper.Mapper.Map<List<SelfAppraisalQuestion>, List<WebSelfAppraisalQuestion>>((List<SelfAppraisalQuestion>)_selfAppraisalRepository.GetAllQuestions()); var listWebAnswers = AutoMapper.Mapper.Map<List<SelfAppraisalAnswer>, List<WebSelfAppraisalAnswer>>((List<SelfAppraisalAnswer>)_selfAppraisalRepository.GetAllAnswers()); for (int i = 0; i < listWebQuestions.Count; i++) { var list = new List<WebSelfAppraisalAnswer>(); list.Add(listWebAnswers[i]); listWebQuestions[i].Answers = list; } bodyResponse.Data = listWebQuestions; bodyResponse.Status = true; } catch (Exception exception) { bodyResponse.Error = exception.Message; } return bodyResponse; }
public WebJsonResponse Authorize([FromBody]OldUser oldUser) { var bodyResponse = new WebJsonResponse(); try { //var session = _sessionRepository.AuthorizeUser(OldUser.Login, OldUser.Password); //var session = _sessionRepository.GetSessionByCredentials(OldUser.Login, OldUser.Password); var authUser = _authorizationRepository.AuthorizeUser(oldUser.Login, oldUser.Password); var body = Mapper.Map<OldUser, AuthorizationContent>(authUser); bodyResponse.Status = true; bodyResponse.Data = body; } catch (Exception exception) { bodyResponse.Error = exception.Message; } return bodyResponse; }
public Object GetMigrationData([FromBody] DateTimePeriod period) { WebJsonResponse response = new WebJsonResponse(); try { Guid token = WebRequestHeaders.GetAuthorizationToken(this); RegistrationContent authorizedPerson = ClientRepository.GetUser(token); if (authorizedPerson == null) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } if (!ClientRepository.CheckAuthorization(token, authorizedPerson.Id, false)) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } if (!Constraints.KAdminClientsId.Contains(authorizedPerson.Id)) { throw new UserRightsException(); } } catch (UnauthorizedException) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); return response; } return _integratorMigrationRepository.GetMigrationData(period); }
public Object UpdateGroup([FromBody]WebGroup webGroup) { var bodyResponse = new WebJsonResponse(); try { var curator = _authorizationRepository.GetUserByCredentials(WebRequestHeaders.GetAuthorizationToken(this)); if (curator == null) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } webGroup.Curator = curator.Id; var group = AutoMapper.Mapper.Map<WebGroup, Group>(webGroup); _groupRepository.UpdateGroup(group); bodyResponse.Data = new object(); bodyResponse.Status = true; } catch(UnauthorizedException) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } catch (Exception exception) { bodyResponse.Error = exception.Message; } return bodyResponse; }
public Object DeleteGroup(long Id) { var bodyResponse = new WebJsonResponse(); try { var curator = _authorizationRepository.GetUserByCredentials(WebRequestHeaders.GetAuthorizationToken(this)); if (curator == null) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } var group = new Group(); group.Id = Id; group.Curator = curator.Id; _groupRepository.DeleteGroup(group); bodyResponse.Data = new object(); bodyResponse.Status = true; } catch(UnauthorizedException) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } catch (Exception exception) { bodyResponse.Error = exception.Message; } return bodyResponse; }
public Object GetSurveysResultsByPerson(long personId) { WebJsonResponse response = new WebJsonResponse(); try { Guid token = WebRequestHeaders.GetAuthorizationToken(this); //RegistrationContent user = ClientRepository.GetUser(token); PersonContent person = ClientRepository.GetPerson(token); if (!ClientRepository.CheckPersonRights(person.Id, personId)) { return new HttpResponseMessage(HttpStatusCode.MethodNotAllowed); } //if (!ClientRepository.CheckAuthorization(token, personId)) //{ // return new HttpResponseMessage(HttpStatusCode.Unauthorized); //} response.Data = Mapper.Map<List<SurveysResult>, List<WebSurveysResult>>( _surveysResultRepository.GetSurveysResults(personId)) ?? new object(); response.Status = true; } catch (UnauthorizedException) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public Object GetSurveysAnswers(long surveysResultId) { WebJsonResponse response = new WebJsonResponse(); try { Guid token = WebRequestHeaders.GetAuthorizationToken(this); Person authorizedPerson = _surveysResultRepository.GetPerson(surveysResultId); if (!ClientRepository.CheckAuthorization(token, authorizedPerson.Id)) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } response.Data = _surveysResultRepository.GetSurveysAnswers(surveysResultId) ?? new object(); response.Status = true; } catch (UnauthorizedException) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }
public Object SetSurveysAnswers(long surveysResultId, [FromBody] List<SurveysAnswerContent> surveysAnswerContents) { WebJsonResponse response = new WebJsonResponse(); try { Guid token = WebRequestHeaders.GetAuthorizationToken(this); Person authorizedPerson = _surveysResultRepository.GetPerson(surveysResultId); if (!ClientRepository.CheckAuthorization(token, authorizedPerson.Id)) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } // Set answers _surveysResultRepository.SetSurveysAnswers(surveysResultId, surveysAnswerContents); // Add check for lusher answers and return special lusherPairScenario List<int> lusherSpecialNumberColors = LusherPairRepository.CheckLusherAnswers(surveysResultId, surveysAnswerContents); if (lusherSpecialNumberColors != null) { // Form lusher pair scenario response.Data = Mapper.Map<List<LusherPairScenarioItem>, List<WebLusherScenarioItem>>(LusherPairRepository.GetSpecialQuestion(lusherSpecialNumberColors)); _surveysResultRepository.CompleteSurveyResult(surveysResultId, false); } else { _surveysResultRepository.CompleteSurveyResult(surveysResultId); } // Create surveyShellResult _surveysResultRepository.CreateSurveyShellResultForTest(surveysResultId, surveysAnswerContents); //Fill Data in profile conclusion ConclusionRepository.GenerateDataProfile(surveysResultId, surveysAnswerContents); // Complete parent surveys for Package or CuratorsGroup when all child surveys is completed _surveysResultRepository.CompleteParentPackageSurvey(surveysResultId); _surveysResultRepository.CompleteParentCuratorSurvey(surveysResultId); if (response.Data == null) { response.Data = new object(); } response.Status = true; } catch (UnauthorizedException) { return new HttpResponseMessage(HttpStatusCode.Unauthorized); } catch (Exception exception) { response.Error = String.Format("exception message: {0} \ninner exception: {1} \nstacktrace: {2}", exception.Message, exception.InnerException, exception.StackTrace); } return response; }