예제 #1
0
        public Task <IActionResult> DeleteStageSO(ShooterSOStageRequest request)
        {
            //Recupero l'elemento dal business layer
            var entity = BasicLayer.GetShooterSOStage(request.ShooterSOStageId);

            //Se l'utente non hai i permessi non posso rimuovere entità con userId nullo
            if (entity == null)
            {
                return(Task.FromResult <IActionResult>(NotFound()));
            }

            //Invocazione del service layer
            var validations = BasicLayer.DeleteShooterSOStage(entity);

            if (validations.Count > 0)
            {
                return(BadRequestTask(validations));
            }

            var shooterSOStagees = BasicLayer.FetchShooterSOStagesByStageId(entity.StageId);
            var shooterIds       = shooterSOStagees.Select(x => x.ShooterId).ToList();
            var shooters         = BasicLayer.FetchShootersByIds(shooterIds);

            //Return contract
            return(Reply(shooterSOStagees.As(x => ContractUtils.GenerateContract(x, shooters.FirstOrDefault(s => s.Id == x.ShooterId)))));
        }
예제 #2
0
        public Task <IActionResult> FetchAllShooterSOStages(StageRequest request)
        {
            //Recupero la lista dal layer
            var entities = BasicLayer.FetchShooterSOStagesByStageId(request.StageId);

            var shooterIds = entities.Select(x => x.ShooterId).ToList();
            var shooters   = BasicLayer.FetchShootersByIds(shooterIds);

            //Ritorno i contratti
            return(Reply(entities.As(x => ContractUtils.GenerateContract(x, shooters.FirstOrDefault(s => s.Id == x.ShooterId)))));
        }