Пример #1
0
        public IHttpActionResult deleteone([FromUri] System.Int32 dashboardPk
                                           )
        {
            aspnetdashboardView result = db.aspnetdashboardDbSet
                                         .Where(p => p.DashboardPk == dashboardPk)
                                         .Select(itm => new aspnetdashboardView()
            {
                DashboardPk          = itm.DashboardPk,
                DashboardName        = itm.DashboardName,
                DashboardDescription = itm.DashboardDescription
            }).FirstOrDefault();

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

            aspnetdashboard entityToDelete = db.aspnetdashboardDbSet
                                             .Where(p => p.DashboardPk == result.DashboardPk)
                                             .FirstOrDefault();

            if (entityToDelete == null)
            {
                return(Ok(result));
            }
            db.aspnetdashboardDbSet.Remove(entityToDelete);
            db.SaveChanges();
            return(Ok(result));
        }
Пример #2
0
        public IHttpActionResult updateone([FromBody] aspnetdashboardView viewToUpdate)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            aspnetdashboard resultEntity = db.aspnetdashboardDbSet
                                           .Where(p => p.DashboardPk == viewToUpdate.DashboardPk)
                                           .FirstOrDefault();

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

            resultEntity.DashboardName        = viewToUpdate.DashboardName;
            resultEntity.DashboardDescription = viewToUpdate.DashboardDescription;
            db.Entry(resultEntity).State      = EntityState.Modified;
            db.SaveChanges();
            aspnetdashboardView result = db.aspnetdashboardDbSet
                                         .Where(p => p.DashboardPk == viewToUpdate.DashboardPk)
                                         .Select(itm => new aspnetdashboardView()
            {
                DashboardPk          = itm.DashboardPk,
                DashboardName        = itm.DashboardName,
                DashboardDescription = itm.DashboardDescription
            }).FirstOrDefault();

            if (result == null)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
Пример #3
0
        public IHttpActionResult addone([FromBody] aspnetdashboardView viewToAdd)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            aspnetdashboard entityToAdd = new aspnetdashboard();

            entityToAdd.DashboardPk          = viewToAdd.DashboardPk;
            entityToAdd.DashboardName        = viewToAdd.DashboardName;
            entityToAdd.DashboardDescription = viewToAdd.DashboardDescription;
            db.aspnetdashboardDbSet.Add(entityToAdd);
            db.SaveChanges();

            aspnetdashboardView result = db.aspnetdashboardDbSet
                                         .Where(p => p.DashboardPk == entityToAdd.DashboardPk)
                                         .Select(itm => new aspnetdashboardView()
            {
                DashboardPk          = itm.DashboardPk,
                DashboardName        = itm.DashboardName,
                DashboardDescription = itm.DashboardDescription
            }).FirstOrDefault();

            if (result == null)
            {
                return(NotFound());
            }
            return(Ok(result));
        }
Пример #4
0
        public IHttpActionResult getone([FromUri] System.Int32 dashboardPk
                                        )
        {
            aspnetdashboardView result = db.aspnetdashboardDbSet
                                         .Where(p => p.DashboardPk == dashboardPk)
                                         .Select(itm => new aspnetdashboardView()
            {
                DashboardPk          = itm.DashboardPk,
                DashboardName        = itm.DashboardName,
                DashboardDescription = itm.DashboardDescription
            }).FirstOrDefault();

            if (result == null)
            {
                return(NotFound());
            }
            return(Ok(result));
        } // the end of public GetOne()-method