示例#1
0
        public ActionResult Index(AllProductImages allproductimages, IEnumerable <HttpPostedFileBase> files)
        {
            var curentUserID = CurrentUserData.UserID;

            foreach (var file in files)
            {
                if (file.ContentLength > 0)
                {
                    var fileName = Path.GetFileName(file.FileName);
                    var path     = Path.Combine(Server.MapPath("~/ProductImages/large"), fileName);
                    file.SaveAs(path);
                    var _filePathData = Guid.NewGuid().ToString() + Path.GetExtension(path);
                    path = Path.Combine(Server.MapPath("~/ProductImages/large"), _filePathData);
                    file.SaveAs(path);
                    Crop(150, 150, file.InputStream, Path.Combine(Server.MapPath("~/ProductImages/thumb/") + _filePathData));

                    allproductimages.ImageName   = fileName;
                    allproductimages.ImagePath   = _filePathData;
                    allproductimages.CreatedDate = DateTime.Now;
                    allproductimages.UpdatedDate = DateTime.Now;
                    allproductimages.UserID      = curentUserID;
                    allproductimages.SupplierID  = CurrentUserData.SupplierID;
                    _repository.Insert(allproductimages);
                    _repository.Save();
                }
            }
            return(RedirectToAction("index"));
        }
示例#2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            AllProductImages allproductimages = await db.AllProductImages.FindAsync(id);

            db.AllProductImages.Remove(allproductimages);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
示例#3
0
        public async Task <ActionResult> Edit([Bind(Include = "Id,ImageName,ImagePath,UserID,CreatedDate,UpdatedDate,Sort,Description,Notes")] AllProductImages allproductimages)
        {
            if (ModelState.IsValid)
            {
                db.Entry(allproductimages).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(allproductimages));
        }
示例#4
0
        // GET: /AllImages/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AllProductImages allproductimages = await db.AllProductImages.FindAsync(id);

            if (allproductimages == null)
            {
                return(HttpNotFound());
            }
            return(View(allproductimages));
        }
示例#5
0
        //public ActionResult DeleteImageID(int ImageIDs)
        //{
        //    try
        //    {

        //    }

        //    catch (Exception ex)
        //    {

        //    }
        //}


        public ActionResult DeleteAll(int[] ImageIDs)
        {
            try
            {
                using (ApplicationDbContext db = new ApplicationDbContext())
                {
                    foreach (int ID in ImageIDs)
                    {
                        AllProductImages obj = db.AllProductImages.Find(ID);
                        db.AllProductImages.Remove(obj);
                    }
                    db.SaveChanges();
                    return(Json(new { Success = true, Ex = "" }));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { Success = false, Ex = ex.Message.ToString() }));
            }
        }