public ActionResult <MethodResult> SaveOrganizationalUnitSettings([FromQuery] Guid userId, [FromBody] OrganizationalUnitSettings unitSettings) { try { var user = ClipperUserController.Get <User>(userId); return(user.Role > Role.User ? new ActionResult <MethodResult>(Factory.GetControllerInstance <IClipperOrganizationalUnitAPI>().SaveOrganizationalUnitSettings(unitSettings)) : Forbid()); } catch (Exception error) { Console.WriteLine(error); return(BadRequest(error.Message)); } }
public ActionResult <IReadOnlyList <OrganizationalUnit> > GetOrganizationalUnits([FromQuery] Guid userId) { try { var user = ClipperUserController.Get <User>(userId); return(user.Role > Role.User ? new ActionResult <IReadOnlyList <OrganizationalUnit> >(Factory.GetControllerInstance <IClipperOrganizationalUnitAPI>().GetOrganizationalUnits(user)) : Forbid()); } catch (Exception error) { Console.WriteLine(error); return(BadRequest(error.Message)); } }
public ActionResult <MethodResult> UpdateOrganizationalUnit([FromQuery] Guid userId, [FromBody] OrganizationalUnit updatedUnit) { try { var user = ClipperUserController.Get <User>(userId); if (user.Role > Role.User) { return(new ActionResult <MethodResult>(Factory.GetControllerInstance <IClipperOrganizationalUnitAPI>().UpdateOrganizationalUnit(updatedUnit))); } } catch (Exception exception) { Console.WriteLine(exception); } return(BadRequest()); }
public ActionResult <MethodResult> AddOrganizationalUnit([FromQuery] Guid userId, [FromQuery] string name, [FromQuery] Guid parentUnitId) { try { var user = ClipperUserController.Get <User>(userId); if (user.Role > Role.User) { return(new ActionResult <MethodResult>(Factory.GetControllerInstance <IClipperOrganizationalUnitAPI>().AddOrganizationalUnit(name, parentUnitId))); } } catch (Exception exception) { Console.WriteLine(exception); } return(BadRequest()); }
public ActionResult <ExtendedUser> GetUserInfo([FromQuery] Guid userId, [FromQuery] Guid requested) { try { var user = ClipperUserController.Get <User>(userId); if (user.Role > Role.User) { return(new ActionResult <ExtendedUser>(Factory.GetControllerInstance <IClipperStaffChiefAPI>().GetUserInfo(requested))); } } catch (Exception exception) { Console.WriteLine(exception); } return(BadRequest()); }
public ActionResult <IReadOnlyList <BasicUserInformation> > GetManageableUsers([FromQuery] Guid userId) { try { var user = ClipperUserController.Get <User>(userId); if (user.Role > Role.User) { return(new ActionResult <IReadOnlyList <BasicUserInformation> >(Factory.GetControllerInstance <IClipperStaffChiefAPI>().GetManageableUsers(userId))); } } catch (Exception exception) { Console.WriteLine(exception); } return(BadRequest()); }
public ActionResult <MethodResult> SetUserOrganizationalUnits([FromQuery] Guid userId, [FromBody] IReadOnlyList <Guid> units) { try { var user = ClipperUserController.Get <User>(userId); if (user.Role > Role.User) { return(new ActionResult <MethodResult>(Factory.GetControllerInstance <IClipperOrganizationalUnitAPI>().SetUserOrganizationalUnits(user, units))); } } catch (Exception exception) { Console.WriteLine(exception); } return(BadRequest()); }
public ActionResult <MethodResult> ChangeSource([FromQuery] Guid userId, [FromBody] Source updatedSource) { try { var user = ClipperUserController.Get <User>(userId); if (user.Role == Role.SystemAdministrator) { return(new ActionResult <MethodResult>(Factory.GetControllerInstance <IClipperSystemAdministratorAPI>().ChangeSource(user, updatedSource))); } } catch (Exception exception) { Console.WriteLine(exception); } return(BadRequest()); }
public ActionResult <MethodResult> AddPrincipalUnit([FromQuery] Guid userId, [FromQuery] string name, [FromQuery] string principalUnitMail) { try { var user = ClipperUserController.Get <User>(userId); if (user.Role == Role.SystemAdministrator) { return(new ActionResult <MethodResult>(Factory.GetControllerInstance <IClipperSystemAdministratorAPI>().AddPrincipalUnit(user, name, principalUnitMail))); } } catch (Exception exception) { Console.WriteLine(exception); } return(BadRequest()); }
public ActionResult <MethodResult> DeleteUser([FromQuery] Guid staffChiefId, [FromQuery] Guid userId) { try { var user = ClipperUserController.Get <User>(staffChiefId); if (user.Role > Role.User) { return(new ActionResult <MethodResult>(Factory.GetControllerInstance <IClipperStaffChiefAPI>().DeleteUser(userId))); } return(Forbid()); } catch (Exception error) { Console.WriteLine(error); return(BadRequest(error.Message)); } }
public ActionResult <MethodResult> ModifyUser([FromQuery] Guid staffChiefId, [FromBody] Tuple <User, IReadOnlyList <Guid> > toModify) { try { if (toModify.Item1.Id == Guid.Empty) { throw new ArgumentNullException(); } var user = ClipperUserController.Get <User>(staffChiefId); if (user.Role > Role.User) { return(new ActionResult <MethodResult>(Factory.GetControllerInstance <IClipperStaffChiefAPI>().ModifyUser(toModify.Item1, toModify.Item2))); } return(Forbid()); } catch (Exception error) { Console.WriteLine(error); return(BadRequest(error.Message)); } }