Example #1
0
 public IssueViewModel PostIssues(IssueViewModel item)
 {
     if (!ModelState.IsValid)
     {
         throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
     }
     item.Id = DataProvider._issues.Last().Id + 1;
     DataProvider._issues.Add(item);
     return item;
 }
Example #2
0
        public void PutIssues(int id, IssueViewModel item)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
            item.Id = id;
            var issue = DataProvider._issues.FirstOrDefault(o => o.Id == id);

            if (issue == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
            DataProvider._issues.Remove(issue);
            DataProvider._issues.Add(item);
        }