Пример #1
0
        public IEnumerable <PrivateCustomerView> Get()
        {
            var models = repo.getAllPrivateCustomers();
            var views  = PrivateCustomerView.getViews(models);

            return(views);
        }
Пример #2
0
        public void Put(int id, PrivateCustomerView view)
        {
            view.id = id;
            var model = view.getModel();

            model.updated = DateTime.UtcNow;
            repo.update(model);
        }
 public HttpResponseMessage Get(int id)
 {
     var model = repo.getPrivateCustomer(id);
     if (model == null)
     {
         return Request.CreateResponse(HttpStatusCode.NotFound);
     }
     else
     {
         var view = new PrivateCustomerView(model);
         return Request.CreateResponse(HttpStatusCode.OK, view);
     }
 }
Пример #4
0
        public HttpResponseMessage Get(int id)
        {
            var model = repo.getPrivateCustomer(id);

            if (model == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }
            else
            {
                var view = new PrivateCustomerView(model);
                return(Request.CreateResponse(HttpStatusCode.OK, view));
            }
        }
        public HttpResponseMessage Post(PrivateCustomerView view)
        {
            var model = view.getModel();
            model.created = DateTime.UtcNow;
            model.updated = DateTime.UtcNow;
            model.enabled = true;
            model.fakeId = Guid.NewGuid();
            model = repo.createPrivateCustomer(model);
            view = new PrivateCustomerView(model);

            var response = Request.CreateResponse<PrivateCustomerView>(HttpStatusCode.Created, view);
            string uri = Url.Route(null, new { id = view.id });
            response.Headers.Location = new Uri(Request.RequestUri, uri);
            return response;
        }
Пример #6
0
        public HttpResponseMessage Post(PrivateCustomerView view)
        {
            var model = view.getModel();

            model.created = DateTime.UtcNow;
            model.updated = DateTime.UtcNow;
            model.enabled = true;
            model.fakeId  = Guid.NewGuid();
            model         = repo.createPrivateCustomer(model);
            view          = new PrivateCustomerView(model);

            var    response = Request.CreateResponse <PrivateCustomerView>(HttpStatusCode.Created, view);
            string uri      = Url.Route(null, new { id = view.id });

            response.Headers.Location = new Uri(Request.RequestUri, uri);
            return(response);
        }
 public void Put(int id, PrivateCustomerView view)
 {
     view.id = id;
     var model = view.getModel();
     model.updated = DateTime.UtcNow;
     repo.update(model);
 }