public ActionResult AddForm(AddFormViewModel vm) { var toEdit = _context.Applications.Include(x => x.Forms).FirstOrDefault(x => x.Id == vm.ApplicationId); if (toEdit == null) { throw new HttpResponseException(HttpStatusCode.BadRequest); } Form form = (Form)Activator.CreateInstance(Type.GetType(vm.FormTypeName)); toEdit.Forms.Add(form); _context.SaveChanges(); return(RedirectToAction("SwapForms", new { id = vm.ApplicationId })); }
public async Task <int> AddForm(AddFormViewModel afvm) { //dynamic jsondata = j_obj; //QForm qf = jsondata.ToObject<QForm>(); //string cid = jsondata.ToString(jsondata.cid); var cid = afvm.cid; QForm qf = afvm.qfom; var ft = qf.FormType; if (ft == 0) { return(0); } return(await _as.AddFormAsync(cid, qf, ft));//return qfid }