public void SaveImages(object sender, ArticleEventArgs e) { var aRep = DependencyResolver.Current.GetService <IArticleRepository>(); if (Images != null) { try { string newPath = "~/Uploads/Images/" + ArticleTypeName + "/" + Uid + "/"; newPath = HttpContext.Current.Request.MapPath(newPath); string oldPath = "~/Uploads/Images/Temp/"; oldPath = HttpContext.Current.Request.MapPath(oldPath); if (!Directory.Exists(newPath)) { Directory.CreateDirectory(newPath); } List <ArticleImage> images = new List <ArticleImage>(); foreach (ImageProperty imageProperty in Images) { if (imageProperty.Id == 0) { File.Move(oldPath + imageProperty.Value, newPath + imageProperty.Value); File.Move(oldPath + imageProperty.Thumbnail, newPath + imageProperty.Thumbnail); } images.Add(this.BuildImageInterface(imageProperty.Id, imageProperty.Value, imageProperty.Thumbnail, imageProperty.Position, imageProperty.Size)); } Images = ImageProperty.BuildXmlProperty(aRep.UpdateAllImages(images)).ToList(); } catch (Exception ex) { throw ex; } } }