コード例 #1
0
        public FullProductViewModel GetSekciqById(int id)
        {
            Sekciq sekciq = this.Context.Sekcii.Find(id);
            FullProductViewModel model = Mapper.Map <Sekciq, FullProductViewModel>(sekciq);

            return(model);
        }
コード例 #2
0
        public DeleteProductViewModel GetDeleteSekciqViewModel(int id)
        {
            Sekciq sekciq = this.Context.Sekcii.Find(id);
            DeleteProductViewModel model = Mapper.Map <Sekciq, DeleteProductViewModel>(sekciq);

            return(model);
        }
コード例 #3
0
        public void DeleteSekcii(DeleteIzdelieBindingModel model)
        {
            Sekciq sekciq = this.Context.Sekcii.Find(model.Id);

            this.Context.Sekcii.Remove(sekciq);
            this.Context.SaveChanges();
        }
コード例 #4
0
        public void AddSekcii(IzdeliqBindingModel model)
        {
            Sekciq sekciq = new Sekciq()
            {
                CatNumber    = model.CatNumber,
                Color        = model.Color,
                Description  = model.Description,
                Price        = model.Price,
                Name         = model.Name,
                Razmeri      = model.Razmeri,
                Type         = model.Type,
                NalichnostBr = model.NalichnostBr
            };
            Supplier supplier = this.Context.Suppliers.Find(model.SupplierId);

            sekciq.Supplier = supplier;
            if (model.ImageName != null && model.ImageName.ContentLength > 0)
            {
                using (var reader = new BinaryReader(model.ImageName.InputStream))
                {
                    sekciq.ImagePicture = reader.ReadBytes(model.ImageName.ContentLength);
                }
            }

            this.Context.Sekcii.Add(sekciq);
            this.Context.SaveChanges();
        }
コード例 #5
0
        public void EditSekcii(EditIzdlieBindingModel model)
        {
            Sekciq sekciq = this.Context.Sekcii.Find(model.Id);

            sekciq.CatNumber    = model.CatNumber;
            sekciq.Color        = model.Color;
            sekciq.Description  = model.Description;
            sekciq.NalichnostBr = model.NalichnostBr;
            sekciq.Name         = model.Name;
            sekciq.Price        = model.Price;
            sekciq.Razmeri      = model.Razmeri;
            sekciq.Type         = model.Type;

            if (model.ImageName != null && model.ImageName.ContentLength > 0)
            {
                using (var reader = new BinaryReader(model.ImageName.InputStream))
                {
                    sekciq.ImagePicture = reader.ReadBytes(model.ImageName.ContentLength);
                }
            }

            this.Context.SaveChanges();
        }