예제 #1
0
        public IHttpActionResult Put([FromODataUri] Guid applicationId, [FromODataUri] string name, Delta <tblApplicationConnection> patch)
        {
            Validate(patch.GetEntity());

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

            tblApplicationConnection tblApplicationConnection = db.tblApplicationConnection.Find(new object[] { applicationId, name });

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

            var userName = User.Identity.Name;

            patch.GetEntity().ModifiedBy   = userName.Substring(userName.LastIndexOf(@"\") + 1);
            patch.GetEntity().ModifiedDate = DateTime.Now;

            patch.Put(tblApplicationConnection);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tblApplicationConnectionExists(applicationId, name))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(tblApplicationConnection));
        }
예제 #2
0
        public IHttpActionResult Put([FromODataUri] Guid applicationId, [FromODataUri] string name, Delta <tblApplicationVariable> patch)
        {
            Validate(patch.GetEntity());

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

            tblApplicationVariable tblApplicationVariable = db.tblApplicationVariable.Find(new object[] { applicationId, name });

            if (tblApplicationVariable == null)
            {
                return(NotFound());
            }
            var userName = User.Identity.Name;

            patch.GetEntity().ModifiedBy = userName == string.Empty ? "user" : userName;

            patch.GetEntity().ModifiedDate = DateTime.Now;

            patch.Put(tblApplicationVariable);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tblApplicationVariableExists(applicationId, name))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(tblApplicationVariable));
        }
예제 #3
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));
        }
예제 #4
0
        // PUT: odata/ConnectionTypes(5)
        public IHttpActionResult Put([FromODataUri] Guid key, Delta <tblConnectionType> patch)
        {
            Validate(patch.GetEntity());

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

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

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

            patch.Put(tblConnectionType);

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

            return(Updated(tblConnectionType));
        }