public BackendUser GetByUserName(String UserName) { BackendUser backendUser = null; try { using (var dbcontext = new FAXPECContext()) { MAIL_USERS_BACKEND d = dbcontext.MAIL_USERS_BACKEND.Where(x => x.USER_NAME.ToUpper() == UserName.ToUpper()).First(); backendUser = AutoMapperConfiguration.FromMailUsersBackendToModel(d); if (backendUser != null && backendUser.UserId >= 0) { var musb = dbcontext.MAIL_USERS_SENDER_BACKEND.Where(x => x.REF_ID_USER == d.ID_USER).ToList(); backendUser.MappedMails = (List <BackEndUserMailUserMapping>) this.GetMailUserByUserId(backendUser.UserId, backendUser.UserRole); } } } catch (Exception e) { if (!e.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Errore nella creazione del profilo utente abilitati per username : "******" E078 Dettagli Errore: " + e.Message, "ERR_078", string.Empty, string.Empty, e.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); log.Error(err); } backendUser = null; } return(backendUser); }
internal static MAIL_USERS_BACKEND MapToMailUsersBackend(BackendUser u, MAIL_USERS_BACKEND b) { b.CODICE_FISCALE = u.CodiceFiscale; b.COGNOME = u.Cognome; b.DEPARTMENT = u.Department; b.DOMAIN = u.Domain; b.NOME = u.Nome; return(b); }
internal static MAIL_USERS_BACKEND MapToMailUsersBackend(BackendUser u) { MAIL_USERS_BACKEND m = new MAIL_USERS_BACKEND() { USER_NAME = u.UserName, ID_USER = u.UserId, COGNOME = u.Cognome, DEPARTMENT = u.Department, ROLE = u.RoleMail.ToString(), NOME = u.Nome, CODICE_FISCALE = u.CodiceFiscale, DOMAIN = u.Domain }; return(m); }
public int Save(BackendUser entity) { int tot = 0; try { using (var dbcontext = new FAXPECContext()) { MAIL_USERS_BACKEND m = new MAIL_USERS_BACKEND(); m = DaoSQLServerDBHelper.MapToMailUsersBackend(entity); dbcontext.MAIL_USERS_BACKEND.Add(m); tot = dbcontext.SaveChanges(); } if (tot != 1) { throw new ManagedException("Utente non inserito", "ERR_BU01", string.Empty, string.Empty, null); } } catch (Exception ex) { if (!ex.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Errore nell'inserimento dell'utente in Users Backend Err_bu01 Dettagli Errore: " + entity.UserName + " " + ex.Message, "ERR_BU01", string.Empty, string.Empty, ex.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); log.Error(err); throw mEx; } else { throw; } } return(tot); }
public void Update(BackendUser entity) { int tot = 0; try { using (var dbcontext = new FAXPECContext()) { MAIL_USERS_BACKEND m = dbcontext.MAIL_USERS_BACKEND.FirstOrDefault(c => c.ID_USER == entity.UserId); m = DaoSQLServerDBHelper.MapToMailUsersBackend(entity, m); dbcontext.MAIL_USERS_BACKEND.Attach(m); dbcontext.Entry(m).State = EntityState.Modified; tot = dbcontext.SaveChanges(); } if (tot != 1) { throw new ManagedException("Utente non aggiornato", "ERR_BU02", string.Empty, string.Empty, null); } } catch (Exception ex) { if (!ex.GetType().Equals(typeof(ManagedException))) { ManagedException mEx = new ManagedException("Errore nell'aggiornamento dell'utente in Users Backend Err_bu02 Dettagli Errore: " + entity.UserName + " " + ex.Message, "ERR_BU02", string.Empty, string.Empty, ex.InnerException); ErrorLogInfo err = new ErrorLogInfo(mEx); log.Error(err); throw mEx; } else { throw; } } }