Example #1
0
        /// <summary>
        /// Saves the service request to the db and updates the version
        /// </summary>
        /// <param name="service_request">service_request to be edited</param>
        /// <returns>boolean</returns>
        /// <exception cref="InvalidOperationException"></exception>
        /// <exception cref="ArgumentNullException"></exception>
        public Boolean edit(service_request serviceRequest)
        {
            ServiceRequestIM im = new ServiceRequestIM(db);
            service_request dbVersion = im.find(serviceRequest.id);
            if (dbVersion.version == serviceRequest.version)
            {
                ((IObjectContextAdapter)db).ObjectContext.Detach(dbVersion);
                db.Entry(serviceRequest).State = EntityState.Modified;

                serviceRequest.version = serviceRequest.version + 1;
                db.SaveChanges();
                return true;
            }
            return false;
        }
 public ServiceRequestController()
 {
     im = new ServiceRequestIM(db);
     om = new ServiceRequestOM(db);
 }