Example #1
0
        private FoodType ConvertDTOToEntity(FoodType_FoodTypeDTO FoodType_FoodTypeDTO)
        {
            FoodType FoodType = new FoodType();

            FoodType.Id           = FoodType_FoodTypeDTO.Id;
            FoodType.Name         = FoodType_FoodTypeDTO.Name;
            FoodType.StatusId     = FoodType_FoodTypeDTO.StatusId;
            FoodType.BaseLanguage = CurrentContext.Language;
            return(FoodType);
        }
Example #2
0
        public async Task <ActionResult <FoodType_FoodTypeDTO> > Get([FromBody] FoodType_FoodTypeDTO FoodType_FoodTypeDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            FoodType FoodType = await FoodTypeService.Get(FoodType_FoodTypeDTO.Id);

            return(new FoodType_FoodTypeDTO(FoodType));
        }
Example #3
0
        public async Task <ActionResult <FoodType_FoodTypeDTO> > Create([FromBody] FoodType_FoodTypeDTO FoodType_FoodTypeDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            FoodType FoodType = ConvertDTOToEntity(FoodType_FoodTypeDTO);

            FoodType = await FoodTypeService.Create(FoodType);

            FoodType_FoodTypeDTO = new FoodType_FoodTypeDTO(FoodType);
            if (FoodType.IsValidated)
            {
                return(FoodType_FoodTypeDTO);
            }
            else
            {
                return(BadRequest(FoodType_FoodTypeDTO));
            }
        }