Esempio n. 1
0
        public static SelectListItem ToSelectListItem(this BeerTypeDto source)
        {
            var result = new SelectListItem();

            result.Value = source.Code.ToString();
            result.Text  = source.Description;

            return(result);
        }
Esempio n. 2
0
        public static BeerTypeDto ToBeerTypeDto(this BeerTypeViewModel source)
        {
            var result = new BeerTypeDto
            {
                Code        = source.Code,
                Description = source.Description
            };

            return(result);
        }
Esempio n. 3
0
        public void UpdateBeerType(BeerTypeDto beerTypeDto)
        {
            //var newType = beerTypeDto.Description;


            var entityToModify = Context.BeerType.Find(beerTypeDto.Code);

            entityToModify.Name = beerTypeDto.Description;

            Context.SaveChanges();
        }
Esempio n. 4
0
        public static BeerTypeDto ToBeerTypeDto(this BeerType source)
        {
            var result = new BeerTypeDto();

            if (source != null)
            {
                result = new BeerTypeDto
                {
                    Code        = source.Id,
                    Description = source.Name
                };
            }
            return(result);
        }
Esempio n. 5
0
        public static BeerType ToBeerType(this BeerTypeDto source)
        {
            if (source == null)
            {
                return(null);
            }
            var result = new BeerType
            {
                Name = source.Description,
                Id   = source.Code
            };

            return(result);
        }
Esempio n. 6
0
        public void CreateBeerType(string type)
        {
            Guid guid;

            guid = Guid.NewGuid();

            BeerTypeDto newBeerTypeDto = new BeerTypeDto
            {
                Code        = guid,
                Description = type
            };

            var newBeerType = newBeerTypeDto.ToBeerType();

            Context.BeerType.Add(newBeerType);
            var result = Context.SaveChanges();
        }