コード例 #1
0
        public async Task<EventViewModel> Post(EventViewModel item)
        {

            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
            item.Id = DataProvider.Calendars.Last().Id + 1;
            DataProvider.Calendars.Add(item);
            return item;
        }
コード例 #2
0
        public void Put(int id, EventViewModel item)
        {
            if (!ModelState.IsValid)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
            item.Id = id;
            var ev = DataProvider.Calendars.FirstOrDefault(o => o.Id == id);

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