Esempio n. 1
0
        public void CheckState(GarmetBM garmentBM)
        {
            Garment garmet = Mapper.Map <GarmetBM, Garment>(garmentBM);

            this.Context.Entry(garmet).State = EntityState.Modified;
            this.Context.SaveChanges();
        }
        public ActionResult Create(GarmetBM garment)
        {
            if (ModelState.IsValid)
            {
                this.service.CreateGarmet(garment);
                return(RedirectToAction("All"));
            }

            return(View(garment));
        }
Esempio n. 3
0
        public void CreateGarmet(GarmetBM garmentBM)
        {
            Garment  garmet     = new Garment();
            GarmetBM garmetBind = garmentBM;

            if (garmentBM != null)
            {
                Mapper.Map <GarmetBM, Garment>(garmetBind);
            }

            garmet.Name        = garmetBind.Name;
            garmet.Quantity    = garmetBind.Quantity;
            garmet.SinglePrice = garmetBind.SinglePrice;
            garmet.Size        = garmetBind.Size;
            garmet.Type        = garmetBind.Type;
            garmet.Pictures    = new List <Picture>();
            garmet.Description = garmetBind.Description;

            if (garmentBM.Picture1 != null)
            {
                garmet.Pictures.Add(
                    new Picture()
                {
                    PictureSourse = String.Format(@"{0}", garmentBM.Picture1.PictureSourse)
                });
            }

            if (garmentBM.Picture2 != null)
            {
                garmet.Pictures.Add(
                    new Picture()
                {
                    PictureSourse = String.Format(@"{0}", garmentBM.Picture2.PictureSourse)
                });
            }
            if (garmentBM.Picture3 != null)
            {
                garmet.Pictures.Add(
                    new Picture()
                {
                    PictureSourse = String.Format(@"{0}", garmentBM.Picture3.PictureSourse)
                });
            }


            this.Context.Clothes.Add(garmet);
            this.Context.SaveChanges();
        }