Example #1
0
        public ActionResult Edit(WatchDTO watch)
        {
            try
            {
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #2
0
        public ActionResult Create(AddGoodViewModel watchVM)
        {
            WatchDTO watchDTO = new WatchDTO();

            watchDTO.Country        = watchVM.Country;
            watchDTO.Description    = watchVM.Description;
            watchDTO.Glass          = watchVM.Glass;
            watchDTO.Manufacturer   = watchVM.Manufacturer;
            watchDTO.Material       = watchVM.Material;
            watchDTO.Model          = watchVM.Model;
            watchDTO.Price          = watchVM.Price;
            watchDTO.Style          = watchVM.Style;
            watchDTO.Weight         = watchVM.Weight;
            watchDTO.WType          = watchVM.WType;
            watchDTO.CountryId      = watchVM.CountryId;
            watchDTO.StyleId        = watchVM.StyleId;
            watchDTO.WTypeId        = watchVM.WTypeId;
            watchDTO.GlassId        = watchVM.GlassId;
            watchDTO.ManufacturerId = watchVM.ManufacturerId;
            watchDTO.MaterialId     = watchVM.MaterialId;

            // Images download to watchDTO
            var folder = Server.MapPath("~/Pictures");

            watchDTO.FolderImg = folder;

            foreach (var img in watchVM.Img)
            {
                ImgInfo imgInfo = new ImgInfo();
                imgInfo.Img = new byte[img.ContentLength];
                img.InputStream.Read(imgInfo.Img, 0, img.ContentLength);
                imgInfo.TypeImg = Path.GetExtension(img.FileName);
                watchDTO.Img.Add(imgInfo);
            }

            watchService.Add(watchDTO);

            return(RedirectToAction("Index"));
        }