//<------------------------------------------------------------------------------------------------------> //<------------------------------------------------------------------------------------------------------> private async Task <OperationResult <int> > Post(CreateSession item) { using (TransactionScope scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { if (!item.ParameterValid()) { return new OperationResult <int>() { Success = false, Message = Messages.PARAMETERS_NOT_NULL } } ; var EventRes = await eventService.GetByIdAsync(item.eventId); if (!EventRes.Success) { return new OperationResult <int>() { Success = false, Message = EventRes.Message } } ; if (!EventRes.Result.community.admins.Any(elem => elem.id == item.userId)) { return new OperationResult <int>() { Success = false, Message = Messages.USER_NO_PERMISSION } } ; if (item.endDate.CompareTo(item.initialDate) <= 0) { return new OperationResult <int>() { Success = false, Message = Messages.END_DATE_NOT_VALID } } ; try { var id = await sessionRepo.PostAsync(item); scope.Complete(); return(new OperationResult <int>() { Success = true, Message = Messages.SESSION_CREATED, Result = id }); } catch (Exception ex) { return(new OperationResult <int>() { Success = false, Message = ex.Message }); } } }