private static void SaveImages(EditProduct editProduct, int productID) { var curList = ProductImages.GetByProductID(productID); foreach (var image in editProduct.Images) { if (!curList.Any(item => item.ID == image.ID)) { var productImage = Mapper.Map <ProductImage>(image); productImage.ProductID = productID; ProductImages.Insert(productImage); } else { ProductImages.UpdateProductImagePlace(image.ID, image.ProductImagePlace); curList.Remove(curList.Single(cls => cls.ID == image.ID)); } } foreach (var item in curList) { ProductImages.Delete(item.ID); } }