public async Task <IActionResult> UpdateEvents([FromBody] SchoolEventChangeModel model) { int userId = _authenticationInfo.ActualUser.UserId; var sqlDataBase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); using (var ctx = new SqlStandardCallContext()) { PeriodServices periodServices = new PeriodServices(); GroupQueries groupQueries = new GroupQueries(ctx, sqlDataBase); EventQueries eventQueries = new EventQueries(ctx, sqlDataBase); if (!await periodServices.CheckPeriodGivenDate(_stObjMap, _authenticationInfo, model.BegDate, model.EndDate)) { Result result = new Result(Status.BadRequest, "Ces Dates ne sont pas comprises dans la periode actuel"); return(this.CreateResult(result)); } GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId); AclQueries aclQueries = new AclQueries(ctx, sqlDataBase); if (!await aclQueries.VerifyGrantLevelByUserId(112, await aclQueries.GetAclIdBySchoolId(groupData.ParentZoneId), userId, Operator.SuperiorOrEqual)) { Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !"); return(this.CreateResult(result)); } await eventQueries.UpdateEvent(model.EventId, model.Name, model.BegDate, model.EndDate); List <EventData> events = await eventQueries.GetAllEventsByIdSchool(groupData.ParentZoneId); return(Ok(events)); } }
public async Task <IActionResult> GetEvents() { int userId = _authenticationInfo.ActualUser.UserId; var sqlDataBase = _stObjMap.StObjs.Obtain <SqlDefaultDatabase>(); using (var ctx = new SqlStandardCallContext()) { GroupQueries groupQueries = new GroupQueries(ctx, sqlDataBase); EventQueries eventQueries = new EventQueries(ctx, sqlDataBase); GroupData groupData = await groupQueries.GetIdSchoolByConnectUser(userId); AclQueries aclQueries = new AclQueries(ctx, sqlDataBase); if (!await aclQueries.VerifyGrantLevelByUserId(112, await aclQueries.GetAclIdBySchoolId(groupData.ParentZoneId), userId, Operator.SuperiorOrEqual)) { Result result = new Result(Status.Unauthorized, "Vous n'etes pas autorisé à utiliser cette fonctionnalité !"); return(this.CreateResult(result)); } List <EventData> events = await eventQueries.GetAllEventsByIdSchool(groupData.ParentZoneId); return(Ok(events)); } }