private User UpdateUser(RepoForm repoFormModel) { // save the input values.. var user = GetLoggedUser() ?? new User() { WinAuthName = User.Identity.Name, FirstLoggedIn = DateTime.Now }; // If userid = 0, meaning they are new, we need to create a new user in the databse if (user.Id == 0) { user = _ctx.Users.Add(user); } return(user); }
/// <summary> /// 获取单个表单(定义/实例) /// </summary> /// <typeparam name="T"></typeparam> /// <param name="isCase"></param> /// <param name="masterID"></param> /// <param name="formID"></param> /// <returns></returns> public T GetForm <T>(int isCase, Guid masterID, Guid formID) { IForm former = null; object form = null; if (isCase == 1) { former = new CaseForm(); form = former.GetForm(formID); } else if (isCase == 0) { former = new RepoForm(); form = former.GetForm(formID); } return((T)form); }
public bool DeleteForm([FromBody] int id) { try { var rf = new RepoForm { Id = id }; _ctx.RepoForms.Attach(rf); _ctx.RepoForms.Remove(rf); _ctx.SaveChanges(); return(true); } catch (Exception) { return(false); } }