示例#1
0
        public void DeletePortmanta(DeleteIzdelieBindingModel model)
        {
            Portmanto portmanto = this.Context.Portmanta.Find(model.Id);

            this.Context.Portmanta.Remove(portmanto);
            this.Context.SaveChanges();
        }
示例#2
0
        public DeleteProductViewModel GetDeletePortmantoViewModel(int id)
        {
            Portmanto portmanto          = this.Context.Portmanta.Find(id);
            DeleteProductViewModel model = Mapper.Map <Portmanto, DeleteProductViewModel>(portmanto);

            return(model);
        }
示例#3
0
        public FullProductViewModel GetPortmantoById(int id)
        {
            Portmanto            portmanto = this.Context.Portmanta.Find(id);
            FullProductViewModel model     = Mapper.Map <Portmanto, FullProductViewModel>(portmanto);

            return(model);
        }
示例#4
0
        public void AddPortmanta(IzdeliqBindingModel model)
        {
            Portmanto portmanto = new Portmanto()
            {
                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);

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

            this.Context.Portmanta.Add(portmanto);
            this.Context.SaveChanges();
        }
示例#5
0
        public void EditPortmanta(EditIzdlieBindingModel model)
        {
            Portmanto portmanto = this.Context.Portmanta.Find(model.Id);

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

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

            this.Context.SaveChanges();
        }