static void CheckUserProfile( User user ) { if( user.Role == SecurityRole.Client ) { //проверить, что профиль подгружается var profile = ClientProfile.Load( user.AcctgID ); } else if( user.Role == SecurityRole.Manager ) { //проверить, что в справочнике сотрудников есть такой сотрудник //var empInfo = AcctgRefCatalog.RmsEmployees[ user.AcctgID ]; //if( empInfo == null ) // throw new BLException( "EmployeesRef doesn't contain record for EmployeeID: " + user.AcctgID ); } else { throw new InvalidOperationException("Unknown user role"); } }
internal static void AddUser( User user, StoreDataContext context ) { context.Users.InsertOnSubmit( user ); //создать запись для сервиса отправки оповещений if( user.Role == SecurityRole.Client ) { var alert = context.ClientAlertInfos.SingleOrDefault( a => a.ClientID == user.AcctgID ); if( alert == null ) context.ClientAlertInfos.InsertOnSubmit( new ClientAlertInfo { ClientID = user.AcctgID, OrderTrackingLastAlertDate = DateTime.Now } ); else alert.OrderTrackingLastAlertDate = DateTime.Now; } context.SubmitChanges(); }