public void EditProduct(string id, string name, int price) { MongodbFunctions mongo = new MongodbFunctions(); ObjectId objID = new ObjectId(id); var picture = Request.Files["picture"]; string path; if (picture != null) { string savePath = System.IO.Path.Combine(Server.MapPath("~/Resources"), name + System.IO.Path.GetExtension(picture.FileName)); picture.SaveAs(savePath); path = name + System.IO.Path.GetExtension(picture.FileName); } else { Databases.DomainModel.Product product = mongo.GetProduct(objID); path = product.Picture; } mongo.UpdateProduct(objID, name, price, path); }