public int SaveAndReturnID(YourObject newObject) { if (ModelState.IsValid) // or CONDITION == TRUE for your case { yourDBContext.YourObjects.Add(newObject); yourDBContext.SaveChanges(); return(newObject.ID); } return(0); // or null or -1, whatever the way you'll understand insertion fails }
public void Configuration(IAppBuilder app) { var container = YourObject.SetupContainer(); // Register the Autofac middleware FIRST. This also adds // Autofac-injected middleware registered with the container. app.UseAutofacMiddleware(container); // ...then register your other middleware not registered // with Autofac. }
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { YourObject yourObject = value as YourObject; return(yourObject.YourArray.Count > 0 ? Visibility.Visible : Visibility.Hidden); }
public ActionResult Test(YourObject input) { return(input.Number.ToString()); }
// function that create an object at a time static void createANewObject() { YourObject newObject = new YourObject(); allObjects.Add(newObject); }