Beispiel #1
0
        public async Task <IHttpActionResult> PutMainViewerViewModels(long id, MainViewerViewModels mainViewerViewModels)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != mainViewerViewModels.Id)
            {
                return(BadRequest());
            }

            db.Entry(mainViewerViewModels).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MainViewerViewModelsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Beispiel #2
0
        public async Task <IHttpActionResult> GetMainViewerViewModels(long id)
        {
            MainViewerViewModels mainViewerViewModels = await db.Viewer.FindAsync(id);

            if (mainViewerViewModels == null)
            {
                return(NotFound());
            }

            return(Ok(mainViewerViewModels));
        }
Beispiel #3
0
        public async Task <IHttpActionResult> PostMainViewerViewModels(MainViewerViewModels mainViewerViewModels)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Viewer.Add(mainViewerViewModels);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = mainViewerViewModels.Id }, mainViewerViewModels));
        }
Beispiel #4
0
        public async Task <IHttpActionResult> DeleteMainViewerViewModels(long id)
        {
            MainViewerViewModels mainViewerViewModels = await db.Viewer.FindAsync(id);

            if (mainViewerViewModels == null)
            {
                return(NotFound());
            }

            db.Viewer.Remove(mainViewerViewModels);
            await db.SaveChangesAsync();

            return(Ok(mainViewerViewModels));
        }