public static DAL.Clerk DtoToDAL(ClerkDTO clerkDTO) { DAL.Clerk clerkDAL = new DAL.Clerk(); clerkDAL.ClerkKey = clerkDTO.ClerkKey; clerkDAL.ClerkFName = clerkDTO.ClerkFName; clerkDAL.ClerkLName = clerkDTO.ClerkLName; clerkDAL.ClerkPassword = clerkDTO.ClerkPassword; clerkDAL.IfManager = clerkDTO.IfManager; return(clerkDAL); }
public static ClerkDTO AddNewClerk(ClerkDTO newClerk, ref string message) { DAL.Clerk IfPasswordExists = db.Clerks.FirstOrDefault(c => c.ClerkPassword == newClerk.ClerkPassword); if (IfPasswordExists != null) { message = "סיסמא זו קיימת במערכת, אנא הקש סיסמא חדשה"; return(null); } DAL.Clerk clerkDAL = DtoToDAL(newClerk); db.Clerks.Add(clerkDAL); db.SaveChanges(); return(newClerk); }
public ClerkDTO(DAL.Clerk clerkDAL) { if (clerkDAL == null) { clerkDAL = new DAL.Clerk(); } ; ClerkKey = clerkDAL.ClerkKey; ClerkFName = clerkDAL.ClerkFName; ClerkLName = clerkDAL.ClerkLName; ClerkPassword = clerkDAL.ClerkPassword; IfManager = clerkDAL.IfManager; }
public static ClerkDTO UpdateClerk(ClerkDTO updatedClerk, ref string message) { DAL.Clerk clerkToUpdate = db.Clerks.FirstOrDefault(c => c.ClerkKey == updatedClerk.ClerkKey); if (clerkToUpdate == null) { message = "לא נמצא משתמש מבוקש"; return(null); } else { clerkToUpdate.ClerkFName = updatedClerk.ClerkFName; clerkToUpdate.ClerkLName = updatedClerk.ClerkLName; clerkToUpdate.ClerkPassword = updatedClerk.ClerkPassword; db.SaveChanges(); } return(updatedClerk); }