Exemplo n.º 1
0
        public void addImage(ApplicationDbContext DB, HttpPostedFileWrapper image) {

            if(DB.galleryImages.Where(g => g.id == id).Any())
            {

                GalleryImage gi = DB.galleryImages.Where(g => g.id == id).FirstOrDefault();
                

                if (image != null && image.ContentLength > 0)
                {

                    string path = "/content/images/uploads/galleries/" + gi.galleryID;
                    bool exists = Directory.Exists(HttpContext.Current.Server.MapPath(path));
                    if (!exists)
                    {
                        Directory.CreateDirectory(HttpContext.Current.Server.MapPath(path));
                    }

                    path = path + "/" + gi.id + Path.GetExtension(image.FileName);
                    image.SaveAs(HttpContext.Current.Server.MapPath(path));
                    gi.image = path;
                }

                DB.SaveChanges();

            }

            

        }
Exemplo n.º 2
0
 public void UploadNow(HttpPostedFileWrapper upload)
 {
     if (upload != null)
     {
         var imageName = upload.FileName;
         var path = Path.Combine(Server.MapPath("~/Upload/Images"), imageName);//TODO перенести путь в config
         upload.SaveAs(path);
     }
 }
Exemplo n.º 3
0
 public void UploadNow(HttpPostedFileWrapper upload)
 {
     if (upload != null)
     {
         var imageName = upload.FileName;
         var path = System.IO.Path.Combine(Server.MapPath("~/Upload/Images"), imageName);
         upload.SaveAs(path);
     }
 }
Exemplo n.º 4
0
        public bool addImage(int galleryID, string title, string text, HttpPostedFileWrapper image, string tag)
        {

            try {

                using (ApplicationDbContext DB = new ApplicationDbContext())
                {

                    ImageGallery gal = DB.gallerys.Where(g => g.id == id).FirstOrDefault();
                    GalleryImage gi = new GalleryImage();
                    gi.galleryID = galleryID;
                    gi.tag = tag;
                    gal.galleryImages.Add(gi);
                    DB.SaveChanges();

                    if (image != null && image.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/galleries/" + galleryID;
                        bool exists = Directory.Exists(HttpContext.Current.Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(HttpContext.Current.Server.MapPath(path));
                        }

                        path = path + "/" + gi.id + Path.GetExtension(image.FileName);
                        image.SaveAs(HttpContext.Current.Server.MapPath(path));
                        gi.image = path;
                    }

                    DB.SaveChanges();

                    gi.addText(DB, text);
                    gi.addTitle(DB, title);



                }

                return true;


            }
            catch(Exception)
            {

                return false;
            }


            
        }
 public ActionResult AddProduct(product_productType_ViewModel model, System.Web.HttpPostedFileWrapper image)
 {
     if (ModelState.IsValid)
     {
         db.products.Add(new product {
             name       = model.product_name, unit_price = model.unit_price, promotion_price = model.promotion_price
             , image    = image.FileName,
             @new       = model.@new, unit = model.unit, description = model.description, id_product_type = model.id_product_type,
             created_at = System.DateTime.Now,
             updated_at = System.DateTime.Now
         });
         image.SaveAs(Server.MapPath(Path.Combine("~/image/product/", image.FileName)));
         db.SaveChanges();
         return(RedirectToAction(actionName: "Index", controllerName: "AdminProduct"));
     }
     return(View(model));
 }
        public ActionResult Edit(product_productType_ViewModel model, System.Web.HttpPostedFileWrapper image)
        {
            var obj = db.products.FirstOrDefault(x => x.id_product == model.id_product);

            obj.name            = model.product_name;
            obj.unit_price      = model.unit_price;
            obj.promotion_price = model.promotion_price;
            if (image != null)
            {
                obj.image = image.FileName;
                image.SaveAs(Server.MapPath(Path.Combine("~/image/product/", image.FileName)));
            }
            obj.id_product_type = model.id_product_type;
            obj.@new            = model.@new;
            obj.unit            = model.unit;

            obj.updated_at      = System.DateTime.Now;
            db.Entry(obj).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index", "AdminProduct"));
        }
Exemplo n.º 7
0
        public JsonResult Create(HttpPostedFileWrapper imageFile)
        {
            JsonResult json = new JsonResult();

            if (imageFile == null || imageFile.ContentLength == 0)
            {

                json.Data = new { status = "no_file" };
                return json;
            }

            var fileName = String.Format("{0}", Guid.NewGuid().ToString());
            var imagePath = Path.Combine(Server.MapPath(Url.Content("~/Content/UserImages")), fileName);

            imageFile.SaveAs(imagePath + ".jpg");

            // resize
            var oryginalImage = Image.FromFile(imagePath + ".jpg");
            var Image800 = ResizeImage(oryginalImage, 600, 800);
            var image200 = ResizeImage(oryginalImage, 200, 200);
            var image450width = ResizeImage(oryginalImage, 450, -1);
            // save to
            Image800.Save(imagePath + "_800.jpg");
            image200.Save(imagePath + "_200.jpg");
            image450width.Save(imagePath + "_450width.jpg");

            // save to db
            var photo = new Photo();
            photo.prefix = fileName;
            photo.MembershipUserID = (Guid)Membership.GetUser().ProviderUserKey;
            db.Photos.Add(photo);
            db.SaveChanges();

            json.Data = new { status = "ok", redirect = Url.Action("Details", "Photo", new { id = photo.PhotoID.ToString() }) };
            return json;
        }
Exemplo n.º 8
0
        public ActionResult Upload(HttpPostedFileWrapper qqfile)
        {
            var extension = Path.GetExtension(qqfile.FileName);
            if (!string.IsNullOrWhiteSpace(extension))
            {
                var mimeType = Config.MimeTypes.FirstOrDefault(p => string.Compare(p.Extension, extension, 0) == 0);

                //если изображение
                if (mimeType != null && PreviewCreator.SupportMimeType(mimeType.Name))
                {
                    //тут сохраняем в файл
                    var filePath = Path.Combine("/Content/files", qqfile.FileName);

                    qqfile.SaveAs(Server.MapPath(filePath));

                    var filePreviewPath = Path.Combine("/Content/files/previews", qqfile.FileName);
                    var previewIconSize = Config.IconSizes.FirstOrDefault(c => c.Name == "AvatarSize");
                    if (previewIconSize != null)
                    {
                        PreviewCreator.CreateAndSavePreview(qqfile.InputStream, new Size(previewIconSize.Width, previewIconSize.Height), Server.MapPath(filePreviewPath));
                    }

                    return Json(new
                    {
                        success = true,
                        result = "error",
                        data = new
                        {
                            filePath,
                            filePreviewPath
                        }
                    });
                }
            }
            return Json(new { error = "Нужно загрузить изображение", success = false });
        }
Exemplo n.º 9
0
        public ActionResult editSchoolStation(int stationID, int schoolID, SchoolStation station, string callback, HttpPostedFileWrapper image)
        {
            ajaxReturnData data = new ajaxReturnData();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {
                    station.id = stationID;
                    DB.Stations.Attach(station);
                    DB.Entry(station).State = EntityState.Unchanged;
                    DB.Entry(station).Property(s => s.line).IsModified = true;
                    DB.Entry(station).Property(s => s.name).IsModified = true;
                    DB.Entry(station).Property(s => s.distance).IsModified = true;

                    if (image != null && image.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/schools/" + schoolID;
                        bool exists = Directory.Exists(Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(Server.MapPath(path));
                        }

                        path = path + "/station" + station.id + Path.GetExtension(image.FileName);
                        image.SaveAs(Server.MapPath(path));
                        station.image = path;
                        DB.Entry(station).Property(s => s.image).IsModified = true;
                    }

                    DB.SaveChanges();
                }


                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                data.message = "station updated";
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to update station; " + ex.Message;
                return Json(data);
            }
        }
Exemplo n.º 10
0
        public ActionResult addLocation(Location location, string callback,  string description, string city, HttpPostedFileWrapper image)
        {
            ajaxReturnData data = new ajaxReturnData();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {
                    
                    
                    DB.Locations.Add(location);
                    DB.SaveChanges();


                    //add name field
                    //Content content = new Content();
                    //content.name = "name";
                    //content.locationID = location.id;
                    //DB.Content.Add(content);
                    //DB.SaveChanges();

                    //ContentBody cb = new ContentBody();
                    //cb.contentID = content.contentID;
                    //cb.code = "en";
                    //cb.body = name;
                    //cb.lastModifiedByID = User.Identity.GetUserId();
                    //cb.lastModified = DateTime.Now;
                    //DB.ContentBody.Add(cb);
                    //DB.SaveChanges();


                    //add description field
                    Content content = new Content();
                    content.name = "description";
                    content.locationID = location.id;
                    DB.Content.Add(content);
                    DB.SaveChanges();

                    ContentBody cb = new ContentBody();
                    cb.contentID = content.contentID;
                    cb.code = "en";
                    cb.body = description;
                    cb.lastModifiedByID = User.Identity.GetUserId();
                    cb.lastModified = DateTime.Now;
                    DB.ContentBody.Add(cb);
                    DB.SaveChanges();

                    ////add city field
                    //content = new Content();
                    //content.name = "city";
                    //content.locationID = location.id;
                    //DB.Content.Add(content);
                    //DB.SaveChanges();

                    //cb = new ContentBody();
                    //cb.contentID = content.contentID;
                    //cb.code = "en";
                    //cb.body = city;
                    //cb.lastModifiedByID = User.Identity.GetUserId();
                    //cb.lastModified = DateTime.Now;
                    //DB.ContentBody.Add(cb);
                    //DB.SaveChanges();


                    if (image != null && image.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/locations/" + location.id;
                        bool exists = Directory.Exists(Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(Server.MapPath(path));
                        }

                        path = path + "/locationImage" + Path.GetExtension(image.FileName);
                        image.SaveAs(Server.MapPath(path));
                        location.image = path;
                        DB.Entry(location).Property(l => l.image).IsModified = true;
                    }
                    

                    //int contentID;
                    //contentID = DB.Content.Where(c => c.locationID == location.id && c.name == "name").FirstOrDefault().contentID;

                    //ContentBody cb = DB.ContentBody.Where(c => c.contentID == contentID && c.code == "en").FirstOrDefault();
                    //cb.body = name;

                    
                    DB.SaveChanges();
                }


                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                data.message = "location added";
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to add location; " + ex.Message;
                return Json(data);
            }
        }
Exemplo n.º 11
0
        public ActionResult editLocation(int locationID, int schoolID, string description, Location location, string callback, HttpPostedFileWrapper image)
        {
            ajaxReturnData data = new ajaxReturnData();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {
                    location.id = locationID;

                    DB.Locations.Attach(location);
                    DB.Entry(location).State = EntityState.Unchanged;
                    DB.Entry(location).Property(l => l.name).IsModified = true;
                    //DB.Entry(location).Property(l => l.city).IsModified = true;
                    location.addContent(DB, "description", description);


                    if (image != null && image.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/locations/" + locationID;
                        //bool existsfirst = System.IO.Directory.Exists(Server.MapPath(path));
                        bool exists = System.IO.Directory.Exists(Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(Server.MapPath(path));
                        }

                        path = path + "/locationImage" + Path.GetExtension(image.FileName);
                        image.SaveAs(Server.MapPath(path));
                        location.image = path;
                        DB.Entry(location).Property(l => l.image).IsModified = true;
                    }
                    DB.SaveChanges();

                    School school = new School();
                    school.id = schoolID;
                    //school.schoolLocation = location;
                    school.locationID = location.id;
                    school.features = new SchoolFeatures();
                    DB.Schools.Attach(school);
                    DB.Entry(school).State = EntityState.Unchanged;
                    DB.Entry(school).Property(s => s.locationID).IsModified = true;

                    DB.SaveChanges();

                    


                }


                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                data.message = "location updated";
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to update location; " + ex.Message;
                return Json(data);
            }
        }
Exemplo n.º 12
0
        public ActionResult addDemography(int courseID, string callback, HttpPostedFileWrapper demographyImage)
        {
            ajaxReturnData data = new ajaxReturnData();

            try
            {
                
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {
                    SchoolCourse course = DB.schoolCourses.Where(c => c.id == courseID).FirstOrDefault();


                    if (demographyImage != null && demographyImage.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/courses/" + course.id;
                        bool exists = Directory.Exists(Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(Server.MapPath(path));
                        }

                        path = path + "/demographyImage" + Path.GetExtension(demographyImage.FileName);
                        demographyImage.SaveAs(Server.MapPath(path));
                        course.demographyImage = path;
                        DB.SaveChanges();
                    }
                    

                }


                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to add demo image; " + ex.Message;
                return Json(data);
            }
        }
Exemplo n.º 13
0
        public string aj_FUpload(string CustId, string YY, string Kind, int limitCount, HttpPostedFileWrapper fileName)
        {
            UpFileResult r = new UpFileResult();

            //Log.Write(fileName.ContentLength.ToString());
            //Log.WriteToFile();
            try
            {
                int size = 1024 * 1024 * 38;

                if (fileName.ContentLength > size)
                {
                    r.result = false;
                    r.message = "檔案太大,需小於38MB!";
                    return defJSON(r);
                }

                string path = "~/Upload/" + YY + "/" + CustId + "/" + Kind + "/";
                string spath = Server.MapPath(path);
                if (!System.IO.Directory.Exists(spath))
                {
                    System.IO.Directory.CreateDirectory(spath);
                }
                else {
                    var files = System.IO.Directory.GetFiles(spath);
                    if (files.Length >= limitCount)
                    {
                        r.result = false;
                        r.message = "檔案數量超過限制:" + limitCount;
                        return defJSON(r);
                    }
                }

                fileName.SaveAs(spath + fileName.FileName);
                r.result = true;
            }
            catch (Exception ex)
            {

                r.result = false;
                r.message = ex.Message;
            }
            return defJSON(r);
        }
Exemplo n.º 14
0
        public WrappedJsonResult EditEventPhoto(HttpPostedFileWrapper imageFile, int Event_Id)
        {
            if (imageFile == null || imageFile.ContentLength == 0)
            {
                return new WrappedJsonResult
                {
                    Data = new
                    {
                        IsValid = false,
                        Message = "No file was uploaded.",
                        ImagePath = string.Empty
                    }
                };
            }

            string mimeType = imageFile.ContentType;
            Stream fileStream = imageFile.InputStream;
            string fileName = Path.GetFileName(imageFile.FileName);
            int fileLength = imageFile.ContentLength;
            byte[] fileData = new byte[fileLength];
            fileStream.Read(fileData, 0, fileLength);

            Event Xevent = db.Events.FirstOrDefault(e => e.Event_Id == Event_Id);
            Xevent.Event_Photo = fileData;
            Xevent.Event_PhotoMimeType = mimeType;
            Xevent.Event_PhotoFileName = fileName;

            //db.Events.Attach(Xevent);
            db.Entry(Xevent).State = EntityState.Modified;
            db.SaveChanges();

            var fileNameZ = String.Format("{0}.jpg", Guid.NewGuid().ToString());
            var imagePath = Path.Combine(Server.MapPath(Url.Content("~/Uploads")), fileNameZ);

            imageFile.SaveAs(imagePath);

            return new WrappedJsonResult
            {
                Data = new
                {
                    IsValid = true,
                    Message = string.Empty,
                    ImagePath = Url.Content(String.Format("~/Uploads/{0}", fileNameZ))
                }
            };
        }
Exemplo n.º 15
0
        public ActionResult editCourseGeneral(string name, int type, string editCourseIntroduction, HttpPostedFileWrapper introductionImage, string callback, int courseID, string languageCode = "en" )
        {
            ajaxReturnData data = new ajaxReturnData();
            SchoolCourse course = new SchoolCourse();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {

                    course = DB.schoolCourses.Where(sc => sc.id == courseID).FirstOrDefault();
                    course.type = type;
                    DB.SaveChanges();

                    if (introductionImage != null && introductionImage.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/courses/" + course.id;
                        bool exists = Directory.Exists(Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(Server.MapPath(path));
                        }

                        path = path + "/introductionImage" + Path.GetExtension(introductionImage.FileName);
                        introductionImage.SaveAs(Server.MapPath(path));
                        course.introductionImage = path;
                        DB.Entry(course).Property(l => l.introductionImage).IsModified = true;
                    }
                    
                    course.addContent(DB, "name",name);
                    course.addContent(DB, "courseIntroduction", editCourseIntroduction);
                    DB.SaveChanges();

                }
                

                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                data.message = "course updated";
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to retrieve course; " + ex.Message;
                return Json(data);
            }
        }
Exemplo n.º 16
0
 public void uploadnow(HttpPostedFileWrapper upload)
 {
     if (upload != null)
     {
         string ImageName = upload.FileName;
         string path = System.IO.Path.Combine(Server.MapPath("/Upload"), ImageName);
         upload.SaveAs(path);
     }
 }
Exemplo n.º 17
0
 public ActionResult InsertProject(FormCollection fc, HttpPostedFileWrapper avatar, HttpPostedFileWrapper slide, string optionsRadios)
 {
     string urlavatar = "/Upload/Default.png";
     string urlslide = "/Upload/Default.png";
     if (avatar != null)
     {
         var allowedExtensions = new[] { ".JPG", ".PNG", ".JPEG", ".GIF" };
         var fileName = Path.GetFileName(avatar.FileName); //getting only file name(ex-ganesh.jpg)
         var ext = (Path.GetExtension(avatar.FileName)).ToUpper(); //getting the extension(ex-.jpg)
         if (allowedExtensions.Contains(ext)) //check what type of extension
         {
             string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
             string myfile = UnitilHelper.convertToUnSign(name) + DateTime.Now.Millisecond.ToString() + ext; //appending the name with id
             string pathavatar = System.IO.Path.Combine(Server.MapPath("/Upload"), myfile);
             urlavatar = "Upload/" + myfile;
             avatar.SaveAs(pathavatar);
         }
     }
     if (slide != null)
     {
         var allowedExtensionsslide = new[] { ".JPG", ".PNG", ".JPEG", ".GIF" };
         var fileNameslide = Path.GetFileName(slide.FileName); //getting only file name(ex-ganesh.jpg)
         var extslide = (Path.GetExtension(slide.FileName)).ToUpper(); //getting the extension(ex-.jpg)
         if (allowedExtensionsslide.Contains(extslide)) //check what type of extension
         {
             string name = Path.GetFileNameWithoutExtension(fileNameslide); //getting file name without extension
             string myfileslide = UnitilHelper.convertToUnSign(name) + DateTime.Now.Millisecond.ToString() + extslide; //appending the name with id
             string pathslide = System.IO.Path.Combine(Server.MapPath("/Upload"), myfileslide);
             urlslide = "Upload/" + myfileslide;
             slide.SaveAs(pathslide);
         }
     }
     try
     {
         Project _pro = new Project()
         {
             Name = fc["nameproject"],
             Title = fc["TitleProject"],
             Keyword = fc["Keyword"],
             MetaDescription = fc["MetaDescription"],
             AreaId = int.Parse(fc["Area"]),
             Banner = urlslide,
             CreateDate = DateTime.Now,
             Description = fc["contentproject"],
             IsActive = true,
             IsDelete = false,
             IsHot = optionsRadios == "SetHot" ? true : false,
             Map = fc["ToadoX"] + "," + fc["ToadoY"],
             OpenDate = DateTime.Now,
             PriceId = int.Parse(fc["Price"]),
             ProjectTypeId = int.Parse(fc["Type"]),
             ShortDes = fc["description"],
             SmallImage = urlavatar
         };
         _projectService.AddNewProject(_pro);
         _unitOfWork.SaveChanges();
     }
     catch
     { }
     return RedirectToAction("Index", "Project");
 }
Exemplo n.º 18
0
        public WrappedJsonResult UploadImage(HttpPostedFileWrapper ImageFile)
        {
            if (ImageFile == null || ImageFile.ContentLength == 0)
            {
                return new WrappedJsonResult
                {
                    Data = new
                    {
                        IsValid = false,
                        Message = "Не удалось загрузить изображение",
                        ImagePath = string.Empty
                    }
                };
            }

            var fileName = String.Format("{0}{1}", Guid.NewGuid().ToString(), Path.GetExtension(ImageFile.FileName));
            var imagePath = Path.Combine(LocalPath.AbsoluteUploadsDirectory, fileName);

            ImageFile.SaveAs(imagePath);

            return new WrappedJsonResult
            {
                Data = new
                {
                    IsValid = true,
                    Message = string.Empty,
                    ImagePath = Url.Content("~/" + Path.Combine(LocalPath.RelativeUploadsDirectory, fileName))
                }
            };
        }
Exemplo n.º 19
0
 public ActionResult UpdateNews(FormCollection fc, HttpPostedFileWrapper avatar)
 {
     int id = int.Parse(fc["id"]);
     News _oldProject = _NewsService.GetNewById(id);
     string urlavatar = _oldProject.Image;
     if (avatar != null)
     {
         var allowedExtensions = new[] { ".JPG", ".PNG", ".JPEG", ".GIF" };
         var fileName = Path.GetFileName(avatar.FileName); //getting only file name(ex-ganesh.jpg)
         var ext = (Path.GetExtension(avatar.FileName)).ToUpper(); //getting the extension(ex-.jpg)
         if (allowedExtensions.Contains(ext)) //check what type of extension
         {
             string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
             string myfile = UnitilHelper.convertToUnSign(name) + DateTime.Now.Millisecond.ToString() + ext; //appending the name with id
             string path = System.IO.Path.Combine(Server.MapPath("/Upload"), myfile);
             urlavatar = "Upload/" + myfile;
             avatar.SaveAs(path);
         }
     }
     try
     {
         _oldProject.Title = fc["NameTitle"];
         _oldProject.CreateDate = DateTime.Now;
         _oldProject.Content = fc["contentNews"];
         _oldProject.ShortDes = fc["description"];
         _oldProject.Keyword = fc["Keyword"];
         _oldProject.MetaDescription = fc["MetaDescription"];
         _oldProject.Image = urlavatar;
         _NewsService.UpdateNew(_oldProject);
         _unitOfWork.SaveChanges();
     }
     catch { }
     return RedirectToAction("Index", "News");
 }
Exemplo n.º 20
0
 public string UpLoadImg(string fileName, string path)
 {
     //上传和返回(保存到数据库中)的路径
     string uppath = string.Empty;
     string savepath = string.Empty;
     if (HttpContext.Current.Request.Files.Count > 0)
     {
         //HttpContext.Current.Request.Files[""];
         HttpPostedFileBase imgFile = new HttpPostedFileWrapper(HttpContext.Current.Request.Files[fileName]);
         if (imgFile != null)
         {
             //创建图片新的名称
             var nameImg = DateTime.Now.ToString("yyyyMMddHHmmssfff");
             //获得上传图片的路径
             var strPath = imgFile.FileName;
             //获得上传图片的类型(后缀名)
             var type = strPath.Substring(strPath.LastIndexOf(".") + 1).ToLower();
             if (!ValidateImg(type)) return savepath;
             //拼写数据库保存的相对路径字符串
             uppath = string.IsNullOrEmpty(path) ? HttpContext.Current.Server.MapPath("~/Uploads/") : HttpContext.Current.Server.MapPath("~/Uploads/" + path + "/");
             savepath += nameImg + "." + type;
             //拼写上传图片的路径
             uppath += nameImg + "." + type;
             //上传图片
             imgFile.SaveAs(uppath);
             return savepath;
         }
     }
     return "";
 }
Exemplo n.º 21
0
        public ActionResult edotShortCourseFeature(int id, string callback, string text, string heading, HttpPostedFileWrapper galleryImage, string languageCode = "en")
        {
            ajaxReturnData data = new ajaxReturnData();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {
                    
                    GalleryImage img = DB.galleryImages.Where(i => i.id == id).FirstOrDefault();
                    

                    if (galleryImage != null && galleryImage.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/galleries/" + img.galleryID;
                        bool exists = Directory.Exists(Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(Server.MapPath(path));
                        }


                        path = path + "/" + img.id + Path.GetExtension(galleryImage.FileName);
                        galleryImage.SaveAs(Server.MapPath(path));
                        img.image = path;
                        DB.SaveChanges();
                    }

                    img.addTitle(DB, heading);
                    img.addText(DB, text);


                }


                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                data.message = "short course feature saved";
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to save short course feature; " + ex.Message;
                return Json(data);
            }
        }
Exemplo n.º 22
0
        public ActionResult editShortCourseGeneral(int id, int schoolID, string descriptionHeading, string bookNowLink, string dates, string video, string name, string url, HttpPostedFileWrapper descriptionImage, HttpPostedFileWrapper videoCover, string callback, string languageCode = "en")
        {
            ajaxReturnData data = new ajaxReturnData();
            ShortCourse course = new ShortCourse();
            

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {

                    if (DB.shortCourses.Where(s => s.url == url && s.id != id).Any())
                    {
                        data.message = "short course url is taken";
                        data.statusCode = (int)statusCodes.fail;
                    }
                    else
                    {
                        course = DB.shortCourses.Where(sc => sc.id == id).FirstOrDefault();
                        course.video = video;
                        course.url = url;
                        course.schoolID = schoolID;
                        course.bookNowLink = bookNowLink;

                        if (descriptionImage != null && descriptionImage.ContentLength > 0)
                        {

                            string path = "/content/images/uploads/shortCourses/" + course.id;
                            bool exists = Directory.Exists(Server.MapPath(path));
                            if (!exists)
                            {
                                Directory.CreateDirectory(Server.MapPath(path));
                            }

                            path = path + "/descriptionImage" + Path.GetExtension(descriptionImage.FileName);
                            descriptionImage.SaveAs(Server.MapPath(path));
                            course.descriptionImage = path;
                            DB.Entry(course).Property(l => l.descriptionImage).IsModified = true;
                        }
                        if (videoCover != null && videoCover.ContentLength > 0)
                        {

                            string path = "/content/images/uploads/shortCourses/" + course.id;
                            bool exists = Directory.Exists(Server.MapPath(path));
                            if (!exists)
                            {
                                Directory.CreateDirectory(Server.MapPath(path));
                            }

                            path = path + "/videoCover" + Path.GetExtension(videoCover.FileName);
                            videoCover.SaveAs(Server.MapPath(path));
                            course.videoCover = path;
                            DB.Entry(course).Property(l => l.videoCover).IsModified = true;
                        }

                        course.addContent(DB, "name", name);
                        course.addContent(DB, "dates", dates);
                        course.addContent(DB, "descriptionHeading", descriptionHeading);
                        DB.SaveChanges();
                    }
                    
                }


                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                data.message = "short course updated";
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to update short course; " + ex.Message;
                return Json(data);
            }
        }
Exemplo n.º 23
0
 public void update(HttpPostedFileWrapper file, FormCollection fc)
 {
     Ads prc = new Ads();
     if (Request.Params["IdUpdate"].Length > 0)
     {
         int id = int.Parse(Request.Params["IdUpdate"]);
         prc = _adsService.GetById(id);
         string url = prc.Image;
         if (Request.Params["NameAds"].Length > 0)
         {
             if (file != null)
             {
                 var allowedExtensions = new[] { ".JPG", ".PNG", ".JPEG", ".GIF" };
                 var fileName = Path.GetFileName(file.FileName); //getting only file name(ex-ganesh.jpg)
                 var ext = (Path.GetExtension(file.FileName)).ToUpper(); //getting the extension(ex-.jpg)
                 if (allowedExtensions.Contains(ext)) //check what type of extension
                 {
                     string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
                     string myfile = UnitilHelper.convertToUnSign(name) + DateTime.Now.Millisecond + ext; //appending the name with id
                     string path = System.IO.Path.Combine(Server.MapPath("/Upload"), myfile);
                     url = "Upload/" + myfile;
                     file.SaveAs(path);
                 }
             }
             prc.Name = fc["NameAds"];
             prc.URL = fc["Url"];
             prc.IsShow = fc["optionsRadios"] == "SetHot" ? true : false;
             prc.Image = url;
             _adsService.UpdateAds(prc);
             _unitOfWork.SaveChanges();
         }
     }
     Response.Redirect("Index");
 }
Exemplo n.º 24
0
        public ActionResult addCourseGeneral(int schoolID, string callback, HttpPostedFileWrapper coursesImage, string coursesHeading)
        {
            ajaxReturnData data = new ajaxReturnData();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {

                    School school = DB.Schools.Where(s => s.id == schoolID).FirstOrDefault();
                    school.addContent(DB, "coursesHeading", coursesHeading);
                    DB.SaveChanges();

                   


                    if (coursesImage != null && coursesImage.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/schools/" + schoolID;
                        //bool existsfirst = System.IO.Directory.Exists(Server.MapPath(path));
                        bool exists = Directory.Exists(Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(Server.MapPath(path));
                        }

                        path = path + "/coursesImage" + Path.GetExtension(coursesImage.FileName);
                        coursesImage.SaveAs(Server.MapPath(path));
                        school.coursesImage = path;
                        DB.Entry(school).Property(s => s.coursesImage).IsModified = true;
                        DB.SaveChanges();
                    }

                    
                    

                   
                }


                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                data.message = "school updated";
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to update school; " + ex.Message;
                return Json(data);
            }
        }
Exemplo n.º 25
0
 public void Insert(FormCollection fc, HttpPostedFileWrapper file)
 {
     if (file != null && fc["NameAds"].ToString() != "")
     {
         Ads _pro = new Ads();
         var allowedExtensions = new[] { ".JPG", ".PNG", ".JPEG", ".GIF" };
         var fileName = Path.GetFileName(file.FileName); //getting only file name(ex-ganesh.jpg)
         var ext = (Path.GetExtension(file.FileName)).ToUpper(); //getting the extension(ex-.jpg)
         if (allowedExtensions.Contains(ext)) //check what type of extension
         {
             string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
             string myfile = UnitilHelper.convertToUnSign(name) + DateTime.Now.Millisecond + ext; //appending the name with id
             string path = System.IO.Path.Combine(Server.MapPath("/Upload"), myfile);
             string urlads = "Upload/" + myfile;
             try
             {
                 file.SaveAs(path);
                 _pro.Image = urlads;
                 _pro.IsDelete = false;
                 _pro.IsShow = fc["optionsRadios"] == "SetHot" ? true : false;
                 _pro.Name = fc["NameAds"];
                 _pro.URL = fc["Url"];
                 _adsService.InsertAds(_pro);
                 _unitOfWork.SaveChanges();
             }
             catch { }
         }
     }
     Response.Redirect("Index");
 }
Exemplo n.º 26
0
        public ActionResult editSchoolGeneral(School school, string name, string callback, HttpPostedFileWrapper videoCover)
        {
            ajaxReturnData data = new ajaxReturnData();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {
                    

                    if (DB.Schools.Where(s => s.url == school.url && s.id != school.id).Any())
                    {
                        data.message = "url is already assigned to another school";
                        data.statusCode = (int)statusCodes.fail;
                    }
                    else{

                        school.addContent(DB, "name", name);

                        //school.id = schoolID;
                        school.features = new SchoolFeatures();


                        //attach school to database then only update fields that arent multilanguage
                        DB.Schools.Attach(school);
                        DB.Entry(school).State = EntityState.Unchanged;
                        DB.Entry(school).Property(s => s.type).IsModified = true;
                        DB.Entry(school).Property(s => s.url).IsModified = true;
                        DB.Entry(school).Property(s => s.previewVideo).IsModified = true;
                        DB.Entry(school).Property(s => s.video).IsModified = true;
                        DB.Entry(school).Property(s => s.address).IsModified = true;
                        DB.Entry(school).Property(s => s.googleMap).IsModified = true;

                        school.loadContent(DB);

                        



                        if (videoCover != null && videoCover.ContentLength > 0)
                        {

                            string path = "/content/images/uploads/schools/" + school.id;
                            bool exists = Directory.Exists(Server.MapPath(path));
                            if (!exists)
                            {
                                Directory.CreateDirectory(Server.MapPath(path));
                            }

                            path = path + "/cover" + Path.GetExtension(videoCover.FileName);
                            videoCover.SaveAs(Server.MapPath(path));
                            school.videoCover = path;
                            DB.Entry(school).Property(s => s.videoCover).IsModified = true;
                            DB.SaveChanges();
                        }
                        


                        if (string.IsNullOrEmpty(callback))
                        {
                            data.statusCode = (int)statusCodes.success;
                        }
                        else
                        {
                            data.statusCode = (int)statusCodes.successRun;
                            data.callback = callback;
                        }

                        data.message = "school '" + school.url + "' updated";
                    }
                    
                }

                return Json(data);

            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to update school; " + ex.Message;
                return Json(data);
            }
        }
        public WrappedJsonResult UploadImage(HttpPostedFileWrapper imageFile)
        {
            if (imageFile == null || imageFile.ContentLength == 0)//Validar que se haya subido el archivo
            {
                return new WrappedJsonResult
                {
                    Data = new
                    {
                        IsValid = false,
                        Message = "El archivo no pudo ser subido.",
                        ImagePath = string.Empty,
                        ThumbnailPath = string.Empty,
                        OriginalFileName = string.Empty
                    }
                };
            }
            else if (imageFile.ContentType != "image/jpeg")//validar que el archivo subido sea una imagen
            {
                return new WrappedJsonResult
                {
                    Data = new
                    {
                        IsValid = false,
                        Message = "El archivo subido no es un archivo de imagen.",
                        ImagePath = string.Empty,
                        ThumbnailPath = string.Empty,
                        OriginalFileName = string.Empty
                    }
                };
            }
            else if (imageFile.ContentLength > 4194304)//Validar que el tamaño no sea mayor al máximo permitido
            {
                return new WrappedJsonResult
                {
                    Data = new
                    {
                        IsValid = false,
                        Message = "El tamaño del archivo es mayor al máximo permitido (4MB).",
                        ImagePath = string.Empty,
                        ThumbnailPath = string.Empty,
                        OriginalFileName = string.Empty
                    }
                };
            }

            var directoryTemp = Server.MapPath("~/UploadImages/");
            if (!Directory.Exists(directoryTemp))
            {
                Directory.CreateDirectory(directoryTemp);
            }
            directoryTemp = Server.MapPath("~/UploadImages/Thumbnails/");
            if (!Directory.Exists(directoryTemp))
            {
                Directory.CreateDirectory(directoryTemp);
            }
            //try
            //{
                //Guardar imagen en el servidor
            string fileName = String.Format("{0}.jpg", new Random().Next(0, 99999).ToString().ToString());
                string imagePath = Path.Combine(Server.MapPath("~/UploadImages"), fileName);
                string thumbnailPath = Path.Combine(Server.MapPath("~/UploadImages/Thumbnails"), fileName);

                //Si el tamaño es mayor al tamaño máximo en que se debe guardar entonces se usa el método para comprimir y guardar
                if (imageFile.ContentLength > 2097152)
                {
                    SaveCompressImage(2097152, imageFile.InputStream, imagePath);
                }
                else
                {
                    imageFile.SaveAs(imagePath);
                }
                //Generar miniatura de la imagen
                GenerateThumbnail(imageFile.InputStream, thumbnailPath);

                //Regresar la ruta de la imagen guardada para mostrarla
                return new WrappedJsonResult
                {
                    Data = new
                    {
                        IsValid = true,
                        Message = string.Empty,
                        ImagePath = Url.Content(String.Format("~/UploadImages/{0}", fileName)),
                        ThumbnailPath = Url.Content(String.Format("~/UploadImages/Thumbnails/{0}", fileName)),
                        OriginalFileName = imageFile.FileName
                    }
                };
            //}
            //catch
            //{
            //    return new WrappedJsonResult
            //    {
            //        Data = new
            //        {
            //            IsValid = false,
            //            Message = "Se ha producido un error al subir el archivo.",
            //            ImagePath = string.Empty,
            //            ThumbnailPath = string.Empty,
            //            OriginalFileName = string.Empty
            //        }
            //    };
            //}
        }
Exemplo n.º 28
0
        public ActionResult editSchoolIntroIntensity(string introduction, int schoolID, int intensity, string callback, HttpPostedFileWrapper introductionImage, HttpPostedFileWrapper intensityImage)
        {
            ajaxReturnData data = new ajaxReturnData();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {

                    School school = DB.Schools.Where(s => s.id == schoolID).FirstOrDefault();
                    school.addContent(DB, "introduction", introduction);
                    DB.SaveChanges();

                    school.intensity = intensity;

                    if (introductionImage != null && introductionImage.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/schools/" + schoolID;
                        bool exists = Directory.Exists(Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(Server.MapPath(path));
                        }

                        path = path + "/introductionImage" + Path.GetExtension(introductionImage.FileName);
                        introductionImage.SaveAs(Server.MapPath(path));
                        school.introductionImage = path;
                    }


                    if (intensityImage != null && intensityImage.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/schools/" + schoolID;
                        bool exists = Directory.Exists(Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(Server.MapPath(path));
                        }

                        path = path + "/intensityImage" + Path.GetExtension(intensityImage.FileName);
                        intensityImage.SaveAs(Server.MapPath(path));
                        school.intensityImage = path;
                    }
                    DB.SaveChanges();
                }


                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                data.message = "school updated";
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to update school; " + ex.Message;
                return Json(data);
            }
        }
Exemplo n.º 29
0
        public ActionResult addCourse(string callback, int schoolID, int type, string name, string courseIntroduction,  HttpPostedFileWrapper introductionImage)
        {
            ajaxReturnData data = new ajaxReturnData();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {


                    SchoolCourse sc = new SchoolCourse();
                    sc.schoolID = schoolID;
                    sc.type = type;
                    DB.schoolCourses.Add(sc);
                    sc.features = new CourseFeatures();
                    DB.SaveChanges();
                    sc.addContent(DB, "name", name);
                    sc.addContent(DB, "courseIntroduction", courseIntroduction);

                    if (introductionImage != null && introductionImage.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/courses/" + sc.id;
                        bool exists = Directory.Exists(Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(Server.MapPath(path));
                        }

                        path = path + "/introductionImage" + Path.GetExtension(introductionImage.FileName);
                        introductionImage.SaveAs(Server.MapPath(path));
                        sc.introductionImage = path;
                        DB.Entry(sc).Property(l => l.introductionImage).IsModified = true;
                        DB.SaveChanges();
                    }




                }


                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                data.message = "course added";
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to add course; " + ex.Message;
                return Json(data);
            }
        }
Exemplo n.º 30
0
        public ActionResult editSchoolFeatures(int schoolID, School school, string callback, string uniqueFeatureText, HttpPostedFileWrapper featuresImage, string uniqueFeature = "")
        {
            ajaxReturnData data = new ajaxReturnData();

            try
            {
                using (ApplicationDbContext DB = new ApplicationDbContext())
                {
                    school.id = schoolID;

                    if (!String.IsNullOrWhiteSpace(uniqueFeature))
                    {
                        school.addContent(DB, "USP", uniqueFeature);
                        school.addContent(DB, "uniqueFeatureText", uniqueFeatureText);
                        DB.SaveChanges();
                    }

                    

                    //features is a complex type, meaning its adding as table columns to schools and can not be null on an update
                    if (school.features == null)
                    {
                        school.features = new SchoolFeatures();
                    }


                    DB.Schools.Attach(school);
                    DB.Entry(school).State = EntityState.Unchanged;

                    if(school.features != null)
                    {
                        DB.Entry(school).Property(s => s.features.studentCafe).IsModified = true;
                        DB.Entry(school).Property(s => s.features.acceptsBeginners).IsModified = true;
                        DB.Entry(school).Property(s => s.features.wifiInCommonAreas).IsModified = true;
                        DB.Entry(school).Property(s => s.features.studentLounge).IsModified = true;
                        DB.Entry(school).Property(s => s.features.studentLounge24hour).IsModified = true;
                        DB.Entry(school).Property(s => s.features.englishStaff).IsModified = true;
                        DB.Entry(school).Property(s => s.features.fullTimeJobSupport).IsModified = true;
                        DB.Entry(school).Property(s => s.features.partTimeJobSupport).IsModified = true;
                        DB.Entry(school).Property(s => s.features.interactWithJapanese).IsModified = true;
                        DB.Entry(school).Property(s => s.features.smallClassSizes).IsModified = true;
                        DB.Entry(school).Property(s => s.features.studentDorms).IsModified = true;
                        DB.Entry(school).Property(s => s.features.uniqueFeature).IsModified = true;

                    }
                    

                    if (featuresImage != null && featuresImage.ContentLength > 0)
                    {

                        string path = "/content/images/uploads/schools/" + schoolID;
                        bool exists = Directory.Exists(Server.MapPath(path));
                        if (!exists)
                        {
                            Directory.CreateDirectory(Server.MapPath(path));
                        }

                        path = path + "/featuresImage" + Path.GetExtension(featuresImage.FileName);
                        featuresImage.SaveAs(Server.MapPath(path));
                        school.featuresImage = path;
                        DB.Entry(school).Property(s => s.featuresImage).IsModified = true;
                    }

                    

                    DB.SaveChanges();
                }


                if (string.IsNullOrEmpty(callback))
                {
                    data.statusCode = (int)statusCodes.success;
                }
                else
                {
                    data.statusCode = (int)statusCodes.successRun;
                    data.callback = callback;
                }

                data.message = "school features updated";
                return Json(data);
            }
            catch (Exception ex)
            {
                data.statusCode = (int)statusCodes.fail;
                data.message = "Failed to update school features; " + ex.Message;
                return Json(data);
            }
        }
Exemplo n.º 31
0
 public ActionResult InsertNews(FormCollection fc, HttpPostedFileWrapper avatar)
 {
     string urlavatar = "/Upload/Default.png";
     if (avatar != null)
     {
         var allowedExtensions = new[] { ".JPG", ".PNG", ".JPEG", ".GIF" };
         var fileName = Path.GetFileName(avatar.FileName); //getting only file name(ex-ganesh.jpg)
         var ext = (Path.GetExtension(avatar.FileName)).ToUpper(); //getting the extension(ex-.jpg)
         if (allowedExtensions.Contains(ext)) //check what type of extension
         {
             string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
             string myfile = UnitilHelper.convertToUnSign(name) + DateTime.Now.Millisecond.ToString() + ext; //appending the name with id
             string path = System.IO.Path.Combine(Server.MapPath("/Upload"), myfile);
             urlavatar = "Upload/" + myfile;
             avatar.SaveAs(path);
         }
     }
     try
     {
         News _news = new News()
         {
             Title = fc["NameTitle"],
             CreateDate = DateTime.Now,
             Content = fc["contentNews"],
             ShortDes = fc["description"],
             Image = urlavatar,
             Keyword = fc["Keyword"],
             MetaDescription = fc["MetaDescription"],
             IsDeleted = false
         };
         _NewsService.CreateNew(_news);
         _unitOfWork.SaveChanges();
     }
     catch { }
     return RedirectToAction("Index", "News");
 }
Exemplo n.º 32
0
        public ActionResult UpdateProject(FormCollection fc, HttpPostedFileWrapper avatar, HttpPostedFileWrapper slide, string optionsRadios)
        {
            int id = int.Parse(fc["id"]);
            Project _oldProject = _projectService.GetProjectById(id);
            string urlavatar = _oldProject.SmallImage;
            string urlslide = _oldProject.Banner;

            if (avatar != null)
            {
                var allowedExtensions = new[] { ".JPG", ".PNG", ".JPEG", ".GIF" };
                var fileName = Path.GetFileName(avatar.FileName); //getting only file name(ex-ganesh.jpg)
                var ext = (Path.GetExtension(avatar.FileName)).ToUpper(); //getting the extension(ex-.jpg)
                if (allowedExtensions.Contains(ext)) //check what type of extension
                {
                    string name = Path.GetFileNameWithoutExtension(fileName); //getting file name without extension
                    string myfile = UnitilHelper.convertToUnSign(name) + DateTime.Now.Millisecond.ToString() + ext; //appending the name with id
                    string path = System.IO.Path.Combine(Server.MapPath("/Upload"), myfile);
                    urlavatar = "Upload/" + myfile;
                    avatar.SaveAs(path);
                }
            }
            if (slide != null)
            {
                var allowedExtensionsslide = new[] { ".JPG", ".PNG", ".JPEG", ".GIF" };
                var fileNameslide = Path.GetFileName(slide.FileName); //getting only file name(ex-ganesh.jpg)
                var extslide = (Path.GetExtension(slide.FileName)).ToUpper(); //getting the extension(ex-.jpg)
                if (allowedExtensionsslide.Contains(extslide)) //check what type of extension
                {
                    string name = Path.GetFileNameWithoutExtension(fileNameslide); //getting file name without extension
                    string myfileslide = UnitilHelper.convertToUnSign(name) + DateTime.Now.Millisecond.ToString() + extslide; //appending the name with id
                    string pathslide = System.IO.Path.Combine(Server.MapPath("/Upload"), myfileslide);
                    urlslide = "Upload/" + myfileslide;
                    slide.SaveAs(pathslide);
                }
            }
            try
            {
                _oldProject.Name = fc["nameproject"];
                _oldProject.Title = fc["TitleProject"];
                _oldProject.Keyword = fc["Keyword"];
                _oldProject.MetaDescription = fc["MetaDescription"];
                _oldProject.AreaId = int.Parse(fc["Area"]);
                _oldProject.Banner = urlslide;
                _oldProject.Description = fc["contentproject"];
                _oldProject.IsHot = optionsRadios == "SetHot" ? true : false;
                _oldProject.Map = fc["ToadoX"];
                _oldProject.PriceId = int.Parse(fc["Price"]);
                _oldProject.ProjectTypeId = int.Parse(fc["Type"]);
                _oldProject.ShortDes = fc["description"];
                _oldProject.SmallImage = urlavatar;
                _projectService.UpdateProject(_oldProject);
                _unitOfWork.SaveChanges();
            }
            catch
            { }
            return RedirectToAction("Index", "Project");
        }