Exemplo n.º 1
0
        public static Establishmment ToEstablishmment(this EstablishmmentToCreate establishmment)
        {
            var validate = Establishmment.Create(establishmment.Name.Trim(), establishmment.Email.Trim(), establishmment.Phone.Trim(), establishmment.Schedule.Open.ToSchedule(), establishmment.Schedule.Close.ToSchedule(), establishmment.Wifi.Rate, establishmment.Noise.Rate, establishmment.Plug.Rate);

            var addres = Address.Create("Sem endereço", "Sem número", "SemCEP", "Sem Local", "SU", establishmment.Latitude, establishmment.Longitude);

            validate.SetAddress(addres);

            return(validate);
        }
Exemplo n.º 2
0
        public async Task <Json> Post([FromBody] EstablishmmentToCreate establishmment)
        {
            var establishmmentValidate = establishmment.ToEstablishmment();

            if (establishmmentValidate.Erro)
            {
                return(Json.BadRequest(establishmmentValidate.Erros, establishmment));
            }

            var repository = SugestionRepository.GetInstance(_context);

            var statusSave = await repository.CreateSingle(establishmmentValidate.ToEstablishmmentSugestion());

            if (statusSave.Erro)
            {
                return(Json.BadRequest(statusSave.Description, establishmment));
            }

            return(Json.Ok(statusSave.Description, establishmment));
        }