Skip to content

Instantly share code, notes, and snippets.

@markholdt
markholdt / gist:83c8ea36aa0f1f4380c1
Created January 5, 2016 07:20
Dropzone for Classifieds
<head>
<!-- include Dropzone css. This is optional, but provides some styling -->
<link href="~/Content/dropzone.css" rel="stylesheet">
</head>
<body>
<!-- include reference to dropzone.js -->
<script src="~/scripts/dropzone.js"></script>
</body>
@markholdt
markholdt / dropzoneWithConfiguration
Last active January 8, 2016 09:40
Dropzone with configuration
<script type="text/javascript">
Dropzone.autoDiscover = false;
$(function() {
// Now that the DOM is fully loaded, create the dropzone & configuration options
var myDropzone = new Dropzone('#my-dropzone', {
maxFilesize: 3.0,
maxFiles: 10,
parallelUploads: 1,
<div id="my-dropzone" action="~/images/upload" class="dropzone"></div>
<input type="hidden" value="" id="Files" name="Files" />
[Route("/images/upload")]
public class UploadImage : IReturn<UploadImageResponse>
{
}
public class UploadImageResponse
{
public string Url { get; set; }
}
@markholdt
markholdt / ImageService
Last active January 5, 2016 08:49
ImageService for uploading multiple images from dropzone
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using ServiceStack;
using System.Drawing;
using System.Drawing.Drawing2D;
[Route("/listings", "GET")]
public class GetListings : IReturn<GetListingsResponse>
{
public int? CategoryId { get; set; }
public int? PriceFrom { get; set; }
public int? PriceTo { get; set; }
}
public class GetListingsResponse
@markholdt
markholdt / GetListings_Search
Created January 8, 2016 05:23
Accessing Request and Response properties within a View
@markholdt
markholdt / pagingRequestResponseDto
Created January 9, 2016 15:59
Paging request & response example
[Route("/listings", "GET")]
public class GetListings : IReturn<GetListingsResponse>
{
// this parameter is used for requesting a specific page
public int? PageNr { get; set; }
// other default request parameters, not needed for paging but included for illustrative purposes
public int? CategoryId { get; set; }
public int? PriceFrom { get; set; }
public int? PriceTo { get; set; }
}
public object GetListings(int? pageNr, int? categoryId, int? priceFrom, int? priceTo)
{
}
@markholdt
markholdt / gist:b6ce8d2d79251092ff8e
Created January 9, 2016 16:36
Paging - jquery bootstrap
<script src="~/scripts/jquery.twbsPagination.min.js"></script>
<script type="text/javascript">
var requestParameters = document.URL.split('?');
var params = '';
if (requestParameters[1] != null) {
var parLines = requestParameters[1].split('&');
var count = 0;
while (parLines[count] != null) {
var t = parLines[count];
if (t.indexOf('PageNr') === -1) {