public EventLocation PostSave(EventLocation location) { if (location.Id > 0) { return LocationService.UpdateLocation(location); } else { return LocationService.CreateLocation(location, Security.GetUserId()); } }
public static EventLocation CreateLocation(EventLocation location, int creator) { var db = ApplicationContext.Current.DatabaseContext.Database; var args = new LocationCreatingEventArgs { Location = location }; OnCreating(args); if (args.Cancel) { return location; } db.Save(location); //Update usersettings and add the newly created calendar to the allowed calendar SecurityService.AddLocationToUser(creator, location.Id); var args2 = new LocationCreatedEventArgs { Location = location }; OnCreated(args2); return location; }
public static EventLocation UpdateLocation(EventLocation location) { ApplicationContext.Current.DatabaseContext.Database.Update(location); return location; }