コード例 #1
0
        // POST: odata/Applications
        public IHttpActionResult Post(tblApplication tblApplication)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            tblApplication.ID           = Guid.NewGuid();
            tblApplication.CreatedBy    = User.Identity.Name;
            tblApplication.ModifiedBy   = User.Identity.Name;
            tblApplication.CreatedDate  = DateTime.Now;
            tblApplication.ModifiedDate = tblApplication.CreatedDate;
            db.tblApplication.Add(tblApplication);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (tblApplicationExists(tblApplication.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(tblApplication));
        }
コード例 #2
0
        // POST: odata/Applications
        public IHttpActionResult Post(tblApplication tblApplication)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.tblApplication.Add(tblApplication);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (tblApplicationExists(tblApplication.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Created(tblApplication));
        }
コード例 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            tblApplication tblApplication = db.tblApplications.Find(id);

            db.tblApplications.Remove(tblApplication);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "Application_ID,Application_Name,Type,Description")] tblApplication tblApplication)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblApplication).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblApplication));
 }
コード例 #5
0
        public ActionResult Create([Bind(Include = "Application_ID,Application_Name,Type,Description")] tblApplication tblApplication)
        {
            if (ModelState.IsValid)
            {
                db.tblApplications.Add(tblApplication);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tblApplication));
        }
コード例 #6
0
        // DELETE: odata/Applications(5)
        public IHttpActionResult Delete([FromODataUri] Guid key)
        {
            tblApplication tblApplication = db.tblApplication.Find(key);

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

            db.tblApplication.Remove(tblApplication);
            db.SaveChanges();

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #7
0
        // GET: Applications/Delete/6
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            tblApplication tblApplication = db.tblApplications.Find(id);

            if (tblApplication == null)
            {
                return(HttpNotFound());
            }
            return(View(tblApplication));
        }
コード例 #8
0
        // PUT: odata/Applications(5)
        public IHttpActionResult Put([FromODataUri] Guid key, Delta <tblApplication> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            tblApplication tblApplication = db.tblApplication.Find(key);

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

            patch.GetEntity().ModifiedDate = DateTime.Now;
            patch.GetEntity().ModifiedBy   = User.Identity.Name;

            patch.Put(tblApplication);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tblApplicationExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(tblApplication));
        }