Skip to content

Instantly share code, notes, and snippets.

View dsibinski's full-sized avatar

Dawid Sibiński dsibinski

View GitHub Profile
[Table("Employees")]
public class Employee
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string Name { get; set; }
public string LastName { get; set; }
}
public class DatePickerFragment : DialogFragment, DatePickerDialog.IOnDateSetListener
{
public static readonly string TAG = "X:" + typeof(DatePickerFragment).Name.ToUpper();
Action<DateTime> _dateSelectedHandler = delegate { };
public DatePickerFragment(Action<DateTime> onDateSelected)
{
_dateSelectedHandler = onDateSelected;
}
private void _btnSelectDate_Click(object sender, EventArgs e)
{
new DatePickerFragment(delegate(DateTime time)
{
_selectedDate = time;
_btnSelectDate.Text = _selectedDate.ToLongDateString();
})
.Show(FragmentManager, DatePickerFragment.TAG);
}
protected override void OnSaveInstanceState(Bundle outState)
{
var tabSelectedPosition = this.ActionBar.SelectedNavigationIndex;
outState.PutInt("selectedTabPosition", tabSelectedPosition);
base.OnSaveInstanceState(outState);
}
protected override void OnRestoreInstanceState(Bundle savedInstanceState)
{
base.OnRestoreInstanceState(savedInstanceState);
var previouslySelectedTabPosition = savedInstanceState.GetInt("selectedTabPosition", 0);
this.ActionBar.SetSelectedNavigationItem(previouslySelectedTabPosition);
}
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/inputEventName"
android:fadingEdge="none" />
public class Car
{
public int Id { get; set; }
public string Producer { get; set; }
public string Model { get; set; }
public DateTime ProductionDate { get; set; }
public bool IsOnWarranty { get; set; }
}
public class CarServiceContext : DbContext
{
// DB connection properties injected automatically
public CarServiceContext() {}
// DB connection properties given explicitly (for Unit Tests)
public CarServiceContext(DbContextOptions options) : base(options) { }
public DbSet<Car> Cars { get; set; }
{
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Warning"
}
},
"Console": {
"LogLevel": {
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<CarServiceContext>(o =>
o.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddMvc();
}