Exemple #1
0
        public HttpResponseMessage Insert(FoodTruck foodTruck)
        {
            var resultado = new HttpResponseMessage();

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    _business.Insert(foodTruck);
                    _businessFuncionario = new FuncionarioBusiness();
                    var entity = _businessFuncionario.GetFuncionarioByEmail(foodTruck.EmailFuncionario);
                    resultado = Request.CreateResponse(HttpStatusCode.OK, entity);
                    scope.Complete();
                }
            }
            catch (ExceptionBusiness ex)
            {
                resultado = ProcessarExcecaoWeb(ex, true);
            }
            catch (Exception ex)
            {
                resultado = ProcessarExcecaoWeb(ex);
            }

            return(resultado);
        }
Exemple #2
0
        public HttpResponseMessage Insert(Funcionario funcionario)
        {
            var resultado = new HttpResponseMessage();

            try
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    if (!string.IsNullOrEmpty(funcionario.NomeFoodTruck))
                    {
                        _businessFoodTruck = new FoodTruckBusiness();
                        var foodTruck = new FoodTruck()
                        {
                            Nome = funcionario.NomeFoodTruck
                        };
                        _businessFoodTruck.Insert(foodTruck);
                        funcionario.FoodTruckFuncionario = new List <FoodTruckFuncionario>();
                        funcionario.FoodTruckFuncionario.Add(new FoodTruckFuncionario()
                        {
                            IdFoodTruck = foodTruck.Id
                        });
                    }

                    funcionario.Perfil = null;
                    _business.Insert(funcionario);
                    resultado = Request.CreateResponse(HttpStatusCode.OK, funcionario);
                    scope.Complete();
                }
            }
            catch (ExceptionBusiness ex)
            {
                resultado = ProcessarExcecaoWeb(ex, true);
            }
            catch (Exception ex)
            {
                resultado = ProcessarExcecaoWeb(ex);
            }

            return(resultado);
        }