Ejemplo n.º 1
0
        public int AddFood(FoodDTO dto)
        {
            int id = 0;

            try
            {
                log.Debug(FoodDTO.FormatFoodDTO(dto));

                R_Food t = FoodDTO.ConvertDTOtoEntity(dto);

                // add
                id         = Repository.AddFood(t);
                dto.FoodId = id;

                log.Debug("result: 'success', id: " + id);
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }

            return(id);
        }
Ejemplo n.º 2
0
        public void DeleteFood(FoodDTO dto)
        {
            try
            {
                log.Debug(FoodDTO.FormatFoodDTO(dto));

                R_Food t = FoodDTO.ConvertDTOtoEntity(dto);

                // delete
                Repository.DeleteFood(t);
                dto.IsDeleted = t.IsDeleted;

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }
Ejemplo n.º 3
0
        public void UpdateFood(FoodDTO dto)
        {
            try
            {
                //Requires.NotNull(t);
                //Requires.PropertyNotNegative(t, "FoodId");

                log.Debug(FoodDTO.FormatFoodDTO(dto));

                R_Food t = FoodDTO.ConvertDTOtoEntity(dto);

                // update
                Repository.UpdateFood(t);

                log.Debug("result: 'success'");
            }
            catch (System.Exception e)
            {
                // error
                log.Error(e.ToString());

                throw;
            }
        }