public async Task <ActionResult> Create([Bind(Include = "idContractFieldTemplate,idContractType,MandatoryField,DefaultValue,AliasField,FieldValue,idContractFieldTypes")] BaseFieldsTemplate baseFieldsTemplate) { if (Management.Management.checkTypeofData(baseFieldsTemplate)) { db.BaseFieldsTemplates.Add(baseFieldsTemplate); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.idContractFieldTypes = new SelectList(db.BaseFieldTypes, "IdContractFieldType", "Name", baseFieldsTemplate.idContractFieldTypes); ViewBag.idContractType = new SelectList(db.BaseTypes, "IdContractType", "NameContractType", baseFieldsTemplate.idContractType); return(View(baseFieldsTemplate)); //if (ModelState.IsValid) //{ // db.BaseFieldsTemplates.Add(baseFieldsTemplate); // await db.SaveChangesAsync(); // return RedirectToAction("Index"); //} //ViewBag.idContractFieldTypes = new SelectList(db.BaseFieldTypes, "IdContractFieldType", "Name", baseFieldsTemplate.idContractFieldTypes); //ViewBag.idContractType = new SelectList(db.BaseTypes, "IdContractType", "NameContractType", baseFieldsTemplate.idContractType); //return View(baseFieldsTemplate); }
public async Task <ActionResult> DeleteConfirmed(int id) { BaseFieldsTemplate baseFieldsTemplate = await db.BaseFieldsTemplates.FindAsync(id); db.BaseFieldsTemplates.Remove(baseFieldsTemplate); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "idContractFieldTemplate,idContractType,MandatoryField,DefaultValue,AliasField,FieldValue,idContractFieldTypes")] BaseFieldsTemplate baseFieldsTemplate) { if (ModelState.IsValid) { db.Entry(baseFieldsTemplate).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.idContractFieldTypes = new SelectList(db.BaseFieldTypes, "IdContractFieldType", "Name", baseFieldsTemplate.idContractFieldTypes); ViewBag.idContractType = new SelectList(db.BaseTypes, "IdContractType", "NameContractType", baseFieldsTemplate.idContractType); return(View(baseFieldsTemplate)); }
// GET: BaseFieldsTemplates/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BaseFieldsTemplate baseFieldsTemplate = await db.BaseFieldsTemplates.FindAsync(id); if (baseFieldsTemplate == null) { return(HttpNotFound()); } return(View(baseFieldsTemplate)); }
public ActionResult createTemplate(BaseFieldsTemplate template) { if (String.IsNullOrEmpty(template.DefaultValue)) template.DefaultValue = "0"; if (ModelState.IsValid) { if (!Template.save(template)) return HttpNotFound(); } // return View(); return RedirectToAction("Index"); }
// GET: BaseFieldsTemplates/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BaseFieldsTemplate baseFieldsTemplate = await db.BaseFieldsTemplates.FindAsync(id); if (baseFieldsTemplate == null) { return(HttpNotFound()); } ViewBag.idContractFieldTypes = new SelectList(db.BaseFieldTypes, "IdContractFieldType", "Name", baseFieldsTemplate.idContractFieldTypes); ViewBag.idContractType = new SelectList(db.BaseTypes, "IdContractType", "NameContractType", baseFieldsTemplate.idContractType); return(View(baseFieldsTemplate)); }
public static bool checkTypeofData(BaseFieldsTemplate template) { var Type = db.BaseFieldTypes.Find(template.idContractFieldTypes); switch (Type.Type1.Name.Trim()) { case "int": int aux; if (int.TryParse(template.FieldValue, out aux)) { return(true); } else { return(false); } case "long": long l; if (long.TryParse(template.FieldValue, out l)) { return(true); } else { return(false); } case "float": float f; if (float.TryParse(template.FieldValue, out f)) { return(true); } else { return(false); } case "double": double d; if (double.TryParse(template.FieldValue, out d)) { return(true); } else { return(false); } case "date": DateTime dateValue; if (DateTime.TryParse(template.FieldValue, out dateValue)) { return(true); } else { return(false); } case "string": break; } return(true); }