Skip to content

Instantly share code, notes, and snippets.

IF @TypeId = 0
BEGIN
SELECT SuggestionId, [Message], [Type]
FROM so_Suggestion main
INNER JOIN so_Suggestion_Model joined ON main.SuggestionId = joined.SuggestionId
WHERE main.[Type] = @TypeId
END
ELSE IF @TypeId = 1
BEGIN
SELECT SuggestionId, [Message], [Type]
// Koppling
suggestion
- id
- message
- submitted_by
- submitted_date
- approved_by
- approved_date
public class SuggestionController<T> : ApiController, ISuggestionController<T> where T : ISuggestion {
public ISuggestionSubmitter<T> Submitter { get; set; }
public SuggestionController(ISuggestionSubmitter<T> submitter) {
Submitter = submitter;
}
[HttpPost]
public JsonResult Create(T suggestion) {
// POST: /api/cars
[HttpPost]
public JsonResult Create(Car request) {
if (!CurrentIdentity.Can(data.SpecialRights.ChangePrice)) {
return Json(ApiResult(Result.RightsError("Du har inte rättighet att skapa objekt.")), JsonRequestBehavior.DenyGet);
}
if (!ModelState.IsValid) {
Response.StatusCode = 422;
// POST: /api/transports
[HttpPost]
public JsonResult Create(Transport request) {
if (!CurrentIdentity.Can(data.SpecialRights.ChangePrice)) {
return Json(ApiResult(Result.RightsError("Du har inte rättighet att skapa objekt.")), JsonRequestBehavior.DenyGet);
}
if (!ModelState.IsValid) {
Response.StatusCode = 422;
@eldewall
eldewall / abc
Last active December 11, 2015 02:18
public class Transformer : ITransformer {
public TransformResult Transform(data.Image original, ImageSpecification spec) {
double load, resize, rotate, create, sharpen;
byte[] imageBytes = null;
using (Bitmap source = ActionTimer.Time(() => { return Load(original); }, out load)) {
using (Bitmap resized = ActionTimer.Time(() => { return Resize(source, spec); }, out resize)) {
ActionTimer.Time(() => { Rotate(resized, original); }, out rotate);
ActionTimer.Time(() => { Sharpen(resized, spec.Sharpen); }, out sharpen);
public ImageCreationResult Create() {
double load, resize, rotate, create, sharpen;
byte[] imageBytes = null;
using (Bitmap source = ActionTimer.Time(() => { return Load(); }, out load)) {
using (Bitmap resized = ActionTimer.Time(() => { return Resize(source); }, out resize)) {
ActionTimer.Time(() => { Rotate(resized); }, out rotate);
ActionTimer.Time(() => { Sharpen(resized); }, out sharpen);
ActionTimer.Time(() => {
imageBytes = ImageTools.CreateJpeg(resized, Spec.Quality);
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NovusDataLayer.Classes;
using data = NovusDataLayer.DataClasses;
using System.Drawing;
using System.Diagnostics;
using System.IO;
using System.Drawing.Imaging;
public class ImageSpec {
public static int DefaultQuality = 85;
public int Sharpen { get; private set; }
public int Quality { get; private set; }
public int Height { get; private set; }
public int Width { get; private set; }
public ImageSpec(int quality, int sharpen, int height, int width) {
Sharpen = sharpen;
private static void GetSize(string size, out int width, out int height) {
height = 0;
switch (size.ToLower()) {
case "largest":
case "4": width = 1024; break;
case "full2":
case "8": width = 900; break;
case "11": width = 640; break;
case "full":
case "1": width = 575; break;