public bool UpdateUser(User user, out string error) { error = string.Empty; try { using (var dbcontext = new WebChatContext()) { var userToUpdate = dbcontext.Users.SingleOrDefault(s => s.UserId == user.UserId); if (userToUpdate == null) { error = "Employee Bulunamadı"; return(false); } userToUpdate.UserName = user.UserName; userToUpdate.Password = user.Password; userToUpdate.Email = user.Email; dbcontext.SaveChanges(); return(true); } } catch (Exception ex) { error = ex.Message; return(false); } }
public bool UpdateEmployee(Employee employee, out string error) { error = string.Empty; try { using (var dbcontext = new WebChatContext()) { var employeeToUpdate = dbcontext.Employees.SingleOrDefault(s => s.Id == employee.Id); if (employeeToUpdate == null) { error = "Employee Bulunamadı"; return(false); } employeeToUpdate.Name = employee.Name; employeeToUpdate.Surname = employee.Surname; employeeToUpdate.Job = employee.Job; dbcontext.SaveChanges(); return(true); } } catch (Exception ex) { error = ex.Message; return(false); } }
public bool CreateUser(User user, out string error) { error = string.Empty; try { using (var dbcontext = new WebChatContext()) { dbcontext.Users.Add(user); dbcontext.SaveChanges(); return(true); } } catch (Exception ex) { error = ex.Message; return(false); } }
public bool CreateEmployee(Employee employee, out string error) { error = string.Empty; try { using (var dbcontext = new WebChatContext()) { dbcontext.Employees.Add(employee); dbcontext.SaveChanges(); return(true); } } catch (Exception ex) { error = ex.Message; return(false); } }
public bool DeleteEmployee(int empID) { string error; try { using (var dbcontext = new WebChatContext()) { var silinecekEmployee = dbcontext.Employees.Where(x => x.Id == empID).FirstOrDefault(); int id = silinecekEmployee.Id; dbcontext.Employees.Remove(silinecekEmployee); dbcontext.SaveChanges(); } return(true); } catch (Exception ex) { error = ex.Message; return(false); } }