public static int AddTask(TaskListVM vm, out string error) { error = ""; try { using (GTDEntities en = new Ef.GTDEntities()) { TaskList t = new TaskList { createdon = DateTime.Now, title = vm.title, description = vm.description, UserId = vm.UserId }; en.TaskLists.Add(t); en.SaveChanges(); return(t.id); } } catch (Exception e) { error = e.Message; return(0); } }
public static int AddUser(User vm, out string error) { error = ""; try { using (GTDEntities en = new Ef.GTDEntities()) { var u = en.Users.Where(x => x.UUID == vm.UUID).FirstOrDefault(); if (u != null) { return(u.id); } vm.createdon = DateTime.Now; en.Users.Add(vm); en.SaveChanges(); return(vm.id); } } catch (Exception e) { error = e.Message; return(0); } }