public IActionResult Correct(int id, [FromBody] EditMagazineInformationModel editMagazineInformationModel) { try { string taskId = _camundaExecutor.GetUnassignedTaskId("GlavniUrednikKorigujePodatke"); dynamic content = new { Name = new CamundaValueItem <string>(editMagazineInformationModel.Name), ISSN = new CamundaValueItem <string>(editMagazineInformationModel.ISSN), IsOpenAccess = new CamundaValueItem <bool>(editMagazineInformationModel.IsOpenAccess), ScientificAreas = new CamundaValueItem <string>(string.Join(",", editMagazineInformationModel.ScientificAreas.Select(x => x.Name))) }; bool actionSucceeded = _camundaExecutor.SubmitTaskForm(taskId, JsonConvert.SerializeObject(content)); if (actionSucceeded) { var magazine = _dataContext.Magazines.FirstOrDefault(x => x.Id == id); magazine.ISSN = editMagazineInformationModel.ISSN; magazine.IsOpenAccess = editMagazineInformationModel.IsOpenAccess; magazine.Name = editMagazineInformationModel.Name; magazine.ScientificAreas = string.Join(",", editMagazineInformationModel.ScientificAreas.Select(x => x.Name)); _dataContext.SaveChanges(); } return(Ok()); } catch (Exception exception) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public IActionResult Register([FromBody] CreateUserModel createUserModel) { try { _camundaExecutor.StartProcess("RegistrationProcess", createUserModel.Username); string taskId = _camundaExecutor.GetUnassignedTaskId("UnosPodataka"); dynamic content = new { Username = new CamundaValueItem <string>(createUserModel.Username), Password = new CamundaValueItem <string>(createUserModel.Password), Firstname = new CamundaValueItem <string>(createUserModel.Firstname), Lastname = new CamundaValueItem <string>(createUserModel.Lastname), City = new CamundaValueItem <string>(createUserModel.City), Country = new CamundaValueItem <string>(createUserModel.Country), Vocation = new CamundaValueItem <string>(createUserModel.Vocation), IsReviewer = new CamundaValueItem <bool>(createUserModel.IsReviewer), ScientificAreas = new CamundaValueItem <string>(string.Join(",", createUserModel.ScientificAreas.Select(x => x.Name))) }; bool actionSucceeded = _camundaExecutor.SubmitTaskForm(taskId, JsonConvert.SerializeObject(content)); if (actionSucceeded) { _dataContext.Users.Add(new User { ScientificAreas = string.Join(",", createUserModel.ScientificAreas.Select(x => x.Name)), City = createUserModel.City, Username = createUserModel.Username, Lastname = createUserModel.Lastname, Firstname = createUserModel.Firstname, Password = createUserModel.Password, Token = Guid.NewGuid().ToString("n"), Country = createUserModel.Country, IsReviewer = createUserModel.IsReviewer, Vocation = createUserModel.Vocation, Role = createUserModel.IsReviewer ? UserRoles.Reviewer.ToString() : UserRoles.User.ToString() }); _dataContext.SaveChanges(); } return(Ok()); } catch (Exception exception) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public IActionResult Create([FromBody] AddMagazineModel addMagazineModel) { try { _camundaExecutor.StartProcess("ProcesKreiranjaNovogCasopisa", User.Identity.Name); string taskId = _camundaExecutor.GetUnassignedTaskId("UnosenjePodatakaZaCasopis"); dynamic content = new { Name = new CamundaValueItem <string>(addMagazineModel.Name), ISSN = new CamundaValueItem <string>(addMagazineModel.ISSN), IsOpenAccess = new CamundaValueItem <bool>(addMagazineModel.IsOpenAccess), ScientificAreas = new CamundaValueItem <string>(string.Join(",", addMagazineModel.ScientificAreas.Select(x => x.Name))) }; bool actionSucceeded = _camundaExecutor.SubmitTaskForm(taskId, JsonConvert.SerializeObject(content)); if (actionSucceeded) { _dataContext.Magazines.Add(new Magazine { ScientificAreas = string.Join(",", addMagazineModel.ScientificAreas.Select(x => x.Name)), ISSN = addMagazineModel.ISSN, ChiefEditor = User.Identity.Name, IsActive = false, IsOpenAccess = addMagazineModel.IsOpenAccess, Name = addMagazineModel.Name }); _dataContext.SaveChanges(); } return(Ok()); } catch (Exception exception) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }