Skip to content

Instantly share code, notes, and snippets.

View enisn's full-sized avatar

Enis Necipoglu enisn

View GitHub Profile
@enisn
enisn / AndroidManifest.xml
Created March 5, 2018 07:25
Xamarin.Forms.Contacts Sample
<uses-permission android:name="android.permission.READ_CONTACTS" />
@enisn
enisn / CheckBox.cs
Created April 20, 2018 10:00
Xamarin Forms CheckBox
using Xamarin.Forms;
namespace Controls
{
public class CheckBox : StackLayout
{
BoxView boxBackground = new BoxView { HeightRequest = 25, WidthRequest = 25, BackgroundColor = Color.LightGray, VerticalOptions = LayoutOptions.CenterAndExpand };
BoxView boxSelected = new BoxView { IsVisible = false, HeightRequest = 18, WidthRequest = 18, BackgroundColor = Color.Accent, VerticalOptions = LayoutOptions.CenterAndExpand, HorizontalOptions = LayoutOptions.Center };
Label lblSelected = new Label { Text = "✓", FontSize=19, FontAttributes= FontAttributes.Bold, IsVisible = false, TextColor = Color.Accent, HorizontalOptions = LayoutOptions.Center, VerticalOptions = LayoutOptions.CenterAndExpand };
Label lblOption = new Label { VerticalOptions = LayoutOptions.CenterAndExpand , FontSize = 14 };
@enisn
enisn / Sample.csproj
Last active April 16, 2020 11:01
Sample.csproj
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.2'">
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<!-- your .net core 2.2 dependencies here -->
</ItemGroup>
@enisn
enisn / Program.cs
Last active April 16, 2020 17:59
Multi-Targeting Program.cs
#if NETCOREAPP2_2
using Microsoft.AspNetCore;
#endif
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
namespace Sample.WebService
{
public class Program
{
@enisn
enisn / Startup.cs
Last active April 16, 2020 11:12
Multi-Targeting Startup.cs
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
@enisn
enisn / ProductsController.cs
Last active April 16, 2020 18:40
Challenge #1 - Solution 1 ProductsController
public class ProductsController
{
private readonly MyDbContext context
public ProductsController(MyDbContext context)
{
this.context = context;
}
[HttpGet]
public async Task<IActionResult> GetAsync([FromQuery]SomeDto filter)
@enisn
enisn / Product.cs
Created April 16, 2020 18:33
Challenge #1 - Problem - Product.cs
public class Product
{
public string Id { get; set; }
public string Name { get; set; }
public string Code { get; set; }
public string Description { get; set; }
public decimal Price { get; set; }
public decimal? ShippingPrice { get; set; }
public int Stock { get; set; }
public DateTime CreateDate { get; set; }
@enisn
enisn / ProductsController.cs
Last active April 16, 2020 18:47
Challenge #1 - Expression - Equal Classical
var query = db.Products.Where(x => x.Code == filter.Code);
@enisn
enisn / ProductsController.cs
Last active May 5, 2020 12:30
Challenge #1 - Expression - Manual
// x =>
var parameter = Expression.Parameter(typeof(Product), "x");
// x => x.Code
var property = Expression.Property(parameter, "Code");
// x.Code == filter.Code
var comparison = Expression.Equal(property, Expression.Constant(filter.Code));
var lambda = Expression.Lambda<Func<Product, bool>>(comparison, parameter);
@enisn
enisn / ProductsController.cs
Created April 16, 2020 18:54
Challenge #1 - Solution 1 - Contains Query Classical
var query = db.Products.Where(x => x.Name.Contains(filter.Name))