public void MessageSend(User Sender) { User Receiver; do { Receiver = SelectUser(); }while (Receiver is null); Console.WriteLine(DesignedStrings.Messagestring + "\nPlease write the subject of your Message :"); string Subject = IC.InputSubject(); Console.WriteLine("What you wanna send"); Message ToSend = new Message { SenderId = Sender.Id, RecieverId = Receiver.Id, Subject = Subject, Data = IC.InputMessage(), Date = DateTime.Now }; using (var context = new IMEntities()) { context.Messages.Add(ToSend); context.SaveChanges(); } Console.WriteLine("Message sent! Press any key to continue"); CreatingLogs.LogMessage(ToSend); Console.ReadKey(); }
public void RegisterUser() { Console.Clear(); Console.WriteLine(DesignedStrings.CreateUsr); Console.WriteLine("\nRegister user"); Console.WriteLine("-------------"); Console.Write("\nEnter username:"******"Enter password:"******"admin" && password == "admin1") { var checkUser = context.Users.SingleOrDefault(c => c.Username == username); if (checkUser == null) { User ToRegister = new User { Username = username, Password = password, Role = UserAccess.SuperAdministrator, RegisterDate = DateTime.Now, IsUserActive = true }; context.Users.Add(ToRegister); context.SaveChanges(); } } else { User ToRegister = new User { Username = username, Password = password, Role = UserAccess.User, RegisterDate = DateTime.Now, IsUserActive = true }; context.Users.Add(ToRegister); context.SaveChanges(); Console.WriteLine("Registration Successful!"); CreatingLogs.LogUser(ToRegister); Console.ReadLine(); } } }