示例#1
0
        public FullProductViewModel GetSpalnqById(int id)
        {
            Spalnq spalnq = this.Context.Spalni.Find(id);
            FullProductViewModel model = Mapper.Map <Spalnq, FullProductViewModel>(spalnq);

            return(model);
        }
示例#2
0
        public void AddSpalnq(IzdeliqBindingModel model)
        {
            Spalnq spalnq = new Spalnq()
            {
                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);

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

            this.Context.Spalni.Add(spalnq);
            this.Context.SaveChanges();
        }
示例#3
0
        public void DeleteSpalnq(DeleteIzdelieBindingModel model)
        {
            Spalnq spalnq = this.Context.Spalni.Find(model.Id);

            this.Context.Spalni.Remove(spalnq);
            this.Context.SaveChanges();
        }
示例#4
0
        public DeleteProductViewModel GetDeleteSpalnqViewModel(int id)
        {
            Spalnq spalnq = this.Context.Spalni.Find(id);
            DeleteProductViewModel model = Mapper.Map <Spalnq, DeleteProductViewModel>(spalnq);

            return(model);
        }
        public void AddSpalnq(IzdeliqBindingModel model)
        {
            Spalnq spalnq = new Spalnq()
            {
                CatNumber    = model.CatNumber,
                Color        = model.Color,
                Description  = model.Description,
                Price        = model.Price,
                Name         = model.Name,
                Razmeri      = model.Razmeri,
                Type         = model.Type,
                NalichnostBr = model.NalichnostBr
            };

            this.Context.Spalni.Add(spalnq);
        }
示例#6
0
        public void EditSpalnq(EditIzdlieBindingModel model)
        {
            Spalnq spalnq = this.Context.Spalni.Find(model.Id);

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

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

            this.Context.SaveChanges();
        }