Esempio n. 1
0
 public GoodsViewModel(GoodsTypes type, Int32 price, Int32 count, String name = null)
 {
     Type = type;
     _name = name;
     _price = price;
     _count = count;
     ChooseCommand = new Command(WhenChoosed);
 }
Esempio n. 2
0
        public ActionResult Add(GoodViewModel good)
        {
            GoodsTypes   type = OwinContext.Get <DatabaseContext>().GoodsTypes.FirstOrDefault(x => x.Id == new Guid(good.GoodsTypes));
            BinaryReader b    = new BinaryReader(good.Image.InputStream);

            byte[] image = b.ReadBytes(good.Image.ContentLength);
            OwinContext.Get <DatabaseContext>().Goods.Add(new Goods()
            {
                Id          = Guid.NewGuid(),
                Title       = good.Title,
                Description = good.Description,
                Price       = good.Price,
                GoodsTypes  = type,
                ImageName   = good.Image.FileName,
                Image       = image
            });
            OwinContext.Get <DatabaseContext>().SaveChanges();
            return(View());
        }