public async Task <JsonResult> CreateConfiguration(CONFIGURATION model) { if (ModelState.IsValid) { var config = new CONFIGURATION { ProductID = model.ProductID, OSName = model.OSName, OSVersion = model.OSVersion, SizeDisplay = model.SizeDisplay, FrontCamera = model.FrontCamera, RearCamera = model.RearCamera, Cpu = model.Cpu, Ram = model.Ram, Rom = model.Rom, SimStatus = model.SimStatus, Battery = model.Battery }; int result = await new ConfigurationDAO().CreateConfiguration(config); if (result == 0) { return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = true, id = result }, JsonRequestBehavior.AllowGet)); } return(Json(new { Success = false }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// parse a <code><process-engine .../></code> element and add it to the list of parsed elements /// </summary> protected internal virtual void parseProcessEngine(Element element, IList <ProcessEngineXml> parsedProcessEngines) { ProcessEngineXmlImpl processEngine = new ProcessEngineXmlImpl(); // set name processEngine.Name = element.attribute(NAME); // set default string defaultValue = element.attribute(DEFAULT); if (string.ReferenceEquals(defaultValue, null) || defaultValue.Length == 0) { processEngine.Default = false; } else { processEngine.Default = bool.Parse(defaultValue); } IDictionary <string, string> properties = new Dictionary <string, string>(); IList <ProcessEnginePluginXml> plugins = new List <ProcessEnginePluginXml>(); foreach (Element childElement in element.elements()) { if (CONFIGURATION.Equals(childElement.TagName)) { processEngine.ConfigurationClass = childElement.Text; } else if (DATASOURCE.Equals(childElement.TagName)) { processEngine.Datasource = childElement.Text; } else if (JOB_ACQUISITION.Equals(childElement.TagName)) { processEngine.JobAcquisitionName = childElement.Text; } else if (PROPERTIES.Equals(childElement.TagName)) { parseProperties(childElement, properties); } else if (PLUGINS.Equals(childElement.TagName)) { parseProcessEnginePlugins(childElement, plugins); } } // set collected properties processEngine.Properties = properties; // set plugins processEngine.Plugins = plugins; // add the process engine to the list of parsed engines. parsedProcessEngines.Add(processEngine); }
// POST: odata/CONFIGURATION public async Task <IHttpActionResult> Post(CONFIGURATION cONFIGURATION) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CONFIGURATIONs.Add(cONFIGURATION); await db.SaveChangesAsync(); return(Created(cONFIGURATION)); }
// DELETE: odata/CONFIGURATION(5) public async Task <IHttpActionResult> Delete([FromODataUri] int key) { CONFIGURATION cONFIGURATION = await db.CONFIGURATIONs.FindAsync(key); if (cONFIGURATION == null) { return(NotFound()); } db.CONFIGURATIONs.Remove(cONFIGURATION); await db.SaveChangesAsync(); return(StatusCode(HttpStatusCode.NoContent)); }
public void ReadFile() { if (String.IsNullOrEmpty(ENVIROMENT) || File.Exists(_PATHFILE)) { foreach (PropertyInfo _prop in typeof(CONFIG_SAP).GetProperties()) { String _KEY = _prop.Name; String _VALUE = READ_VALUE(_KEY); STRING_CONNECT += String.Format("{0}={1} ", _KEY, _VALUE); CONFIGURATION.GetType().GetProperty(_KEY).SetValue(CONFIGURATION, _VALUE); } STRING_CONNECT = STRING_CONNECT.Trim(); } else { throw new Exception("FILE ERROR: El Archivo de configuración no existe para el ambiente indicado."); } }
public async Task <int> CreateConfiguration(CONFIGURATION model) { try { if (db.PRODUCTs.FindAsync(model.ProductID) == null) { return(0); } db.CONFIGURATIONs.Add(model); await db.SaveChangesAsync(); return(model.ConfigID); } catch { return(0); } }
public async Task <IHttpActionResult> Patch([FromODataUri] int key, Delta <CONFIGURATION> patch) { Validate(patch.GetEntity()); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } CONFIGURATION cONFIGURATION = await db.CONFIGURATIONs.FindAsync(key); if (cONFIGURATION == null) { return(NotFound()); } patch.Patch(cONFIGURATION); try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CONFIGURATIONExists(key)) { return(NotFound()); } else { throw; } } return(Updated(cONFIGURATION)); }