public async Task <ActionResult> CreateJson( string option_id, string option_name, string username, List <OptionDetailsModel> jsonString) { OptionsModel model = new OptionsModel(db); //COPR16_OPTIONVAL_MSTR cOPR16_OPTIONVAL_MSTR = await db.COPR16_OPTIONVAL_MSTR.FindAsync(option_id); COPR16_OPTIONVAL_MSTR cOPR16_OPTIONVAL_MSTR = new COPR16_OPTIONVAL_MSTR(); cOPR16_OPTIONVAL_MSTR.CRE_BY = username; cOPR16_OPTIONVAL_MSTR.ADATE = today; cOPR16_OPTIONVAL_MSTR.OPTION_ID = option_id; cOPR16_OPTIONVAL_MSTR.OPTION_NAME = option_name; model.cOPR16_OPTIONVAL_MSTR = new COPR16_OPTIONVAL_MSTR(); model.option_id = option_id; model.option_name = option_name; model.jsonString = jsonString; foreach (OptionDetailsModel item in jsonString) { COPR16_OPTDTVALUE_MSTR cOPR16_OPTDTVALUE_MSTR = db.COPR16_OPTDTVALUE_MSTR.Where(row => row.OPTION_ID.Contains(option_id) && row.OPTDT_ID.Contains(item.OPTDT_ID)).FirstOrDefault(); if (cOPR16_OPTDTVALUE_MSTR == null) { COPR16_OPTDTVALUE_MSTR dtdt = new COPR16_OPTDTVALUE_MSTR(); dtdt.OPTION_ID = option_id; dtdt.OPTDT_ID = item.OPTDT_ID; dtdt.OPTDT_VALUE = item.OPTDT_VALUE; dtdt.FLGDEF = item.FLGDEF.ToLower() == "true" ? true : false; dtdt.CRE_BY = username; dtdt.FLGACT = true; dtdt.DESC = item.DESC; dtdt.ADATE = today; db.COPR16_OPTDTVALUE_MSTR.Add(dtdt); await db.SaveChangesAsync(); } else { cOPR16_OPTDTVALUE_MSTR.OPTION_ID = option_id; cOPR16_OPTDTVALUE_MSTR.OPTDT_VALUE = item.OPTDT_VALUE; cOPR16_OPTDTVALUE_MSTR.FLGDEF = item.FLGDEF == "true" ? true : false; cOPR16_OPTDTVALUE_MSTR.MOD_BY = username; cOPR16_OPTDTVALUE_MSTR.FLGACT = true; cOPR16_OPTDTVALUE_MSTR.DESC = item.DESC; cOPR16_OPTDTVALUE_MSTR.MOD_DATE = today; db.Entry(cOPR16_OPTDTVALUE_MSTR).State = EntityState.Modified; await db.SaveChangesAsync(); } } db.COPR16_OPTIONVAL_MSTR.Add(cOPR16_OPTIONVAL_MSTR); await db.SaveChangesAsync(); return(View()); }
public async Task <ActionResult> DeleteConfirmed(string id) { COPR16_OPTDTVALUE_MSTR cOPR16_OPTDTVALUE_MSTR = await db.COPR16_OPTDTVALUE_MSTR.FindAsync(id); db.COPR16_OPTDTVALUE_MSTR.Remove(cOPR16_OPTDTVALUE_MSTR); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "OPTDT_ID,OPTION_ID,OPTDT_VALUE,DESC,FLGDEF,FLGACT,ADATE,CRE_BY,MOD_DATE,MOD_BY")] COPR16_OPTDTVALUE_MSTR cOPR16_OPTDTVALUE_MSTR) { if (ModelState.IsValid) { db.Entry(cOPR16_OPTDTVALUE_MSTR).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(cOPR16_OPTDTVALUE_MSTR)); }
// GET: COPR16_OPTDTVALUE_MSTR/Delete/5 public async Task <ActionResult> Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } COPR16_OPTDTVALUE_MSTR cOPR16_OPTDTVALUE_MSTR = await db.COPR16_OPTDTVALUE_MSTR.FindAsync(id); if (cOPR16_OPTDTVALUE_MSTR == null) { return(HttpNotFound()); } return(View(cOPR16_OPTDTVALUE_MSTR)); }
public async Task <ActionResult> SaveJson( string option_id, string option_name, string username, List <OptionDetailsModel> jsonString) { OptionsModel model = new OptionsModel(db); //IEnumerable<OptionDetailsModel> lineitems = Deserialise<IEnumerable<OptionDetailsModel>>(jsonString); COPR16_OPTIONVAL_MSTR cOPR16_OPTIONVAL_MSTR = await db.COPR16_OPTIONVAL_MSTR.FindAsync(option_id); if (cOPR16_OPTIONVAL_MSTR == null) { return(HttpNotFound()); } //cOPR16_OPTIONVAL_MSTR.MOD_BY = System.Security.Principal.WindowsIdentity.GetCurrent().Name; cOPR16_OPTIONVAL_MSTR.MOD_BY = username; cOPR16_OPTIONVAL_MSTR.MOD_DATE = today; cOPR16_OPTIONVAL_MSTR.OPTION_ID = option_id; cOPR16_OPTIONVAL_MSTR.OPTION_NAME = option_name; model.cOPR16_OPTIONVAL_MSTR = new COPR16_OPTIONVAL_MSTR(); model.option_id = option_id; model.option_name = option_name; model.jsonString = jsonString; foreach (OptionDetailsModel item in jsonString) { COPR16_OPTDTVALUE_MSTR cOPR16_OPTDTVALUE_MSTR = db.COPR16_OPTDTVALUE_MSTR.Where(row => row.OPTION_ID.Contains(option_id) && row.OPTDT_ID.Contains(item.OPTDT_ID)).FirstOrDefault(); if (cOPR16_OPTDTVALUE_MSTR == null) { COPR16_OPTDTVALUE_MSTR dtdt = new COPR16_OPTDTVALUE_MSTR(); dtdt.OPTION_ID = option_id; dtdt.OPTDT_ID = item.OPTDT_ID; dtdt.OPTDT_VALUE = item.OPTDT_VALUE; dtdt.FLGDEF = item.FLGDEF.ToLower() == "true" ? true : false; dtdt.CRE_BY = username; dtdt.FLGACT = true; dtdt.DESC = item.DESC; dtdt.ADATE = today; db.COPR16_OPTDTVALUE_MSTR.Add(dtdt); await db.SaveChangesAsync(); } else { cOPR16_OPTDTVALUE_MSTR.OPTION_ID = option_id; //cOPR16_OPTDTVALUE_MSTR.OPTDT_ID = item.OPTDT_ID; cOPR16_OPTDTVALUE_MSTR.OPTDT_VALUE = item.OPTDT_VALUE; cOPR16_OPTDTVALUE_MSTR.FLGDEF = item.FLGDEF == "true" ? true : false; cOPR16_OPTDTVALUE_MSTR.MOD_BY = username; cOPR16_OPTDTVALUE_MSTR.FLGACT = true; cOPR16_OPTDTVALUE_MSTR.DESC = item.DESC; cOPR16_OPTDTVALUE_MSTR.MOD_DATE = today; db.Entry(cOPR16_OPTDTVALUE_MSTR).State = EntityState.Modified; await db.SaveChangesAsync(); } } db.Entry(cOPR16_OPTIONVAL_MSTR).State = EntityState.Modified; await db.SaveChangesAsync(); return(View(model)); }