public int SaveFormCode(int id, FormSourceData code) { var form = _context.FormSourceData.Where(f => f.Id == id).FirstOrDefault(); form.FormSourceCode = code.FormSourceCode; _context.SaveChanges(); if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } return(id); }
public int CreateForm(string formTitle) { FormSourceData form = new FormSourceData(); form.FormName = formTitle; form.FormSourceDataGuid = Guid.NewGuid(); form.CreatedDate = DateTime.Now; form.DeletedDate = null; form.FormDescription = "default description"; if (!ModelState.IsValid) { throw new HttpResponseException(HttpStatusCode.BadRequest); } _context.FormSourceData.Add(form); _context.SaveChanges(); int formID = _context.FormSourceData.Max(p => p.Id); return(formID); }