private bool UpdateData() { using (MyAcademyEntities db = new MyAcademyEntities()) { Models.Task UpdatedData = db.Tasks.Where(x => x.ID_task == SelectedID).FirstOrDefault(); if (GoCheck.IsEmpityOrMaxChar(textBoxName.Text) && GoCheck.IsStringValue(textBoxName.Text)) { UpdatedData.Name_task = GoCheck.ClearValue; } else { return(false); } if (GoCheck.isDate(dateTimeDeadline.Value)) { UpdatedData.DeadLine = dateTimeDeadline.Value; } else { return(false); } return(GoCheck.isSave(db.SaveChanges())); } }
private bool Create() { using (MyAcademyEntities db = new MyAcademyEntities()) { Models.Task Newdata = new Models.Task(); if (GoCheck.IsEmpityOrMaxChar(textBoxName.Text) && GoCheck.IsStringValue(textBoxName.Text)) { Newdata.Name_task = GoCheck.ClearValue; } else { return(false); } if (GoCheck.isDate(dateTimeDeadline.Value)) { Newdata.DeadLine = dateTimeDeadline.Value; Newdata.Status_task = true; } else { return(false); } db.Tasks.Add(Newdata); return(GoCheck.isSave(db.SaveChanges())); } }