コード例 #1
0
        public async Task <IActionResult> CreateShooter(ShooterCreateRequest request)
        {
            //Creazione modello richiesto da admin
            var model = new Shooter
            {
                FirstName                    = request.FirstName,
                LastName                     = request.LastName,
                BirthDate                    = request.BirthDate,
                Email                        = request.Email,
                Username                     = request.Username,
                FirearmsLicence              = request.FirearmsLicence,
                FirearmsLicenceExpireDate    = request.FirearmsLicenceExpireDate,
                FirearmsLicenceReleaseDate   = request.FirearmsLicenceReleaseDate,
                MedicalExaminationExpireDate = request.MedicalExaminationExpireDate,
                BirthLocation                = request.BirthLocation,
                Address                      = request.Address,
                City       = request.City,
                PostalCode = request.PostalCode,
                Province   = request.Province,
                Country    = request.Country,
                Phone      = request.Phone,
                FiscalCode = request.FiscalCode
            };

            //Invocazione del service layer
            var validations = await BasicLayer.CreateShooter(model, PlatformUtils.GetIdentityUserId(User));

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

            //Return contract
            return(Ok(ContractUtils.GenerateContract(model)));
        }