public Int64 SaveLogMode([FromBody] EBaseEntity eDriver) { // ELogisticsDriver oldDriver = table.SelectByID<ELogisticsDriver>(eDriver.id); // oldDriver.driverLogMode = eDriver.driverLogMode; // return table.Save(oldDriver); return(0); }
static public async Task <EUserAuth> CreateUserFromMobile(EBaseEntity eNewUser) { try { EUserAuth eUserAuth = new EUserAuth { }; using (var context = new SMySQLContext()) { if (context.BaseUsers.Any(x => x.email == eNewUser.email)) { eUserAuth.respCreateUser = (int)RespCreateUser.EmailExists; return(eUserAuth); } eNewUser.id = Guid.NewGuid().ToString(); eNewUser.creationDateUTC = DateTime.UtcNow; eNewUser.modificationDateUTC = DateTime.UtcNow; eNewUser.lastAccessUTC = DateTime.UtcNow; eNewUser.status = (int)UserStatus.Enabled; EBaseEntity result = context.BaseUsers.AddAsync(eNewUser).Result.Entity; await context.SaveChangesAsync(); eUserAuth.id = result.id; eUserAuth.cpf = result.cpf; eUserAuth.name = result.name; eUserAuth.token = STokens.GenerateToken(eNewUser.email); eUserAuth.authenticated = true; eUserAuth.respCreateUser = (int)RespCreateUser.Ok; } return(eUserAuth); } catch (Exception e) { SLogger.LogError(e); } return(null); }
static public EBaseEntity GetByID(string id) { using (var context = new SMySQLContext()) { EBaseEntity eDriver = context.LogisticsDrivers.SingleOrDefault(x => x.id == id); return(eDriver); } }
static public EBaseEntity GetByID(string id) { using var context = new SMySQLContext(); EBaseEntity eBaseEntity = context.BaseUsers.SingleOrDefault(x => x.id == id); return(eBaseEntity); }
//=====================================================GETS ABOVE===================================================== #region Save static public async Task <string> Save(EBaseEntity eBaseEntity) { eBaseEntity.modificationDateUTC = DateTime.UtcNow; eBaseEntity.type = EntityType.Supplier; using var context = new SMySQLContext(); if (string.IsNullOrEmpty(eBaseEntity.id)) { eBaseEntity.id = Guid.NewGuid().ToString(); eBaseEntity.creationDateUTC = DateTime.UtcNow; var e = await context.BaseUsers.AddAsync(eBaseEntity); await context.SaveChangesAsync(); eBaseEntity.id = e.Entity.id; } else { var e = context.BaseUsers.Update(eBaseEntity); await context.SaveChangesAsync(); eBaseEntity.id = e.Entity.id; } SBaseAddresses.SaveClientAddresses(eBaseEntity.id, eBaseEntity.addressList); return(eBaseEntity.id); }
public Int64 SaveDriverStatus([FromBody] EBaseEntity eDriver) { //ELogisticsDriver oldDriver = table.SelectByID<ELogisticsDriver>(eDriver.id); /* if (oldDriver.driverStatus == (int)DriverStatus.NotEnabled && eDriver.driverStatus == (int)DriverStatus.OffTime) { * //vamos notificar o motorista que o cadastro dele foi aprovado. * var ePush = new EPush { * driverID = oldDriver.id, * title = "Seu cadastro foi aprovado", * message = "Boas viagens!", * pushType = (int)PushKey.DriverEnabled, * directionType = (int)PushDirectionType.ToDriver, * creationDateUTC = DateTime.UtcNow, * firebaseToken = oldDriver.firebaseToken, * key1 = ((int)PushKey.DriverEnabled).ToString(), * value1 = $"{oldDriver.id}", * sendNotification = true * }; * var sPush = SDefines.ApplicationContainer.Resolve<SPush>(); * var pushSent = await sPush.SendPush(ePush); * * string title = "Uttili - Cadastro Aprovado"; * string body = $"Olá {oldDriver.name}, seu cadastro foi liberado com sucesso. Basta fazer o login no aplicativo e boas viagens!"; * bool ok = await SEmail.SendEmail("Uttili", oldDriver.email, title, body); * } * ChangeDriverStatus(eDriver.id, (DriverStatus)eDriver.driverStatus); * if (eDriver.adminUserID.HasValue) SCompaniesAdminUsersLogs.Insert(new ECompanyAdminUserLog { * adminUserID = eDriver.adminUserID.Value, * creationDateUTC = DateTime.UtcNow, * driverID = eDriver.id, * content = "Alterando status do motorista para " + ((DriverStatus)eDriver.driverStatus).ToString() * }); * return eDriver.id;*/ return(0); }
//=====================================================GETS ABOVE===================================================== #region Save static public async Task <string> Save(EBaseEntity eDriver) { eDriver.modificationDateUTC = DateTime.UtcNow; eDriver.type = EntityType.Driver; using (var context = new SMySQLContext()) { if (string.IsNullOrEmpty(eDriver.id)) { eDriver.id = Guid.NewGuid().ToString(); eDriver.creationDateUTC = DateTime.UtcNow; var e = await context.BaseUsers.AddAsync(eDriver); await context.SaveChangesAsync(); return(e.Entity.id); } else { // ELogisticsDriver oldDriver = context.LogisticsDrivers.SingleOrDefault(x => x.id == eDriver.id); // eDriver.password = eDriver.password; var e = context.BaseUsers.Update(eDriver); await context.SaveChangesAsync(); return(e.Entity.id); } } }
public async Task <IActionResult> Save([FromBody] EBaseEntity eDriver) { if (string.IsNullOrEmpty(eDriver.mobile)) { eDriver.mobile = null; //senao o mysql reclama: Duplicate entry '' for key 'mobile_UNIQUE' } var result = await SLogisticsDrivers.Save(eDriver); return(Ok(result)); }
public Int64 SaveNotifications([FromBody] EBaseEntity eDriver) { //if (eDriver.id < 1) return -1; // ELogisticsDriver oldDriver = table.SelectByID<ELogisticsDriver>(eDriver.id); // oldDriver.maxNotificationsKM = eDriver.maxNotificationsKM; // oldDriver.indicateAreasWithMoreRequests = eDriver.indicateAreasWithMoreRequests; // oldDriver.indicateAreasWithMoreValue = eDriver.indicateAreasWithMoreValue; // return table.Save(oldDriver); return(0); }
static public bool SaveProfile(EBaseEntity eBaseEntity) { using var context = new SMySQLContext(); EBaseEntity oldEntity = context.BaseUsers.SingleOrDefault(x => x.id == eBaseEntity.id); oldEntity.email = eBaseEntity.email; oldEntity.password = eBaseEntity.password; context.BaseUsers.Update(oldEntity); return(SBaseAddresses.SaveClientAddresses(eBaseEntity.id, eBaseEntity.addressList)); }
public string CreateDriver([FromBody] EBaseEntity eDriver) { // if (string.IsNullOrEmpty(eDriver.mobile)) eDriver.mobile = null; //senao o mysql reclama: Duplicate entry '' for key 'mobile_UNIQUE' // eDriver.creationDateUTC = DateTime.UtcNow; // eDriver.lastAccessUTC = DateTime.UtcNow; // eDriver.driverStatus = (int)DriverStatus.NotEnabled; // table.Save(eDriver); // //eDriver.id = // //SDriverPictures.Save(eDriver); // return eDriver.id; return(""); }
static public EBaseEntity GetByID(string id, bool includeAddresses = false) { using var context = new SMySQLContext(); EBaseEntity eBaseEntity = context.BaseUsers.SingleOrDefault(x => x.id == id); eBaseEntity.password = ""; if (includeAddresses) { eBaseEntity.addressList = SBaseAddresses.GetClientAddresses(id); } return(eBaseEntity); }
static private EUserAuth GetUserAuthFromBaseEntity(EBaseEntity eBaseEntity) { EUserAuth eUserAuth = new EUserAuth { id = eBaseEntity.id, companyID = eBaseEntity.companyID, cpf = eBaseEntity.cpf, name = eBaseEntity.name, token = STokens.GenerateToken(eBaseEntity.email + "-" + eBaseEntity.password) }; return(eUserAuth); }
public Int64 SavePaymentConfig([FromBody] EBaseEntity eDriver) { //if (eDriver.id < 1) return -1; // ELogisticsDriver oldDriver = table.SelectByID<ELogisticsDriver>(eDriver.id); // oldDriver.bankID = eDriver.bankID; // oldDriver.bankAccount = eDriver.bankAccount; // oldDriver.bankAgency = eDriver.bankAgency; // oldDriver.bankOwner = eDriver.bankOwner; // oldDriver.bankCPF = eDriver.bankCPF; // oldDriver.bankWaitInDays = eDriver.bankWaitInDays; // return table.Save(oldDriver); return(0); }
public async Task <IActionResult> CreateUserFromMobile([FromBody] EBaseEntity eNewUser) { EUserAuth eUserAuth = await SBaseEntities.CreateUserFromMobile(eNewUser); if (eUserAuth != null) { return(Ok(eUserAuth)); } else { return(BadRequest()); } }
static public async Task <bool> Remove(string id) { using var context = new SMySQLContext(); EBaseEntity eBaseEntity = context.BaseUsers.SingleOrDefault(x => x.id == id); if (eBaseEntity == null) { return(false); } context.Remove(eBaseEntity); await context.SaveChangesAsync(); return(true); }
public Int64 SaveVehicleInfo([FromBody] EBaseEntity eDriver) { //if (eDriver.id < 1) return -1;//esa funcao é usada só apos o update na tela de edicao de dados do veiculo // ELogisticsDriver oldDriver = table.SelectByID<ELogisticsDriver>(eDriver.id); // oldDriver.plateNumber = eDriver.plateNumber; // oldDriver.vehicleRenavam = eDriver.vehicleRenavam; // oldDriver.vehicleChassis = eDriver.vehicleChassis; // oldDriver.vehicleYear = eDriver.vehicleYear; // oldDriver.vehicleColorID = eDriver.vehicleColorID; // oldDriver.vehicleCategoryID = eDriver.vehicleCategoryID; // oldDriver.vehicleID = eDriver.vehicleID; // return table.Save(oldDriver); return(0); }
static public EUserAuth Authenticate(string email, string password) { using var context = new SMySQLContext(); EBaseEntity eBaseEntity = context.BaseUsers.SingleOrDefault(x => x.email == email && x.password == password); if (eBaseEntity == null) { return new EUserAuth { authenticated = false } } ; EUserAuth eUserAuth = GetUserAuthFromBaseEntity(eBaseEntity); eUserAuth.authenticated = true; return(eUserAuth); }
//=====================================================GETS ABOVE===================================================== #region Save static public async Task <string> Save(EBaseEntity eBaseEntity) { eBaseEntity.modificationDateUTC = DateTime.UtcNow; using (var context = new SMySQLContext()) { if (string.IsNullOrEmpty(eBaseEntity.id)) { eBaseEntity.id = Guid.NewGuid().ToString(); eBaseEntity.creationDateUTC = DateTime.UtcNow; var e = await context.BaseUsers.AddAsync(eBaseEntity); await context.SaveChangesAsync(); return(e.Entity.id); } else { var e = context.BaseUsers.Update(eBaseEntity); await context.SaveChangesAsync(); return(e.Entity.id); } } }
public IActionResult GetByID(string id) { EBaseEntity eBaseEntity = SCompaniesSuppliers.GetByID(id); return(Ok(eBaseEntity)); }
public async Task <IActionResult> Save([FromBody] EBaseEntity eBaseEntity) { var result = await SCompaniesEmployees.Save(eBaseEntity); return(Ok(result)); }
public IActionResult GetByID(string id) { EBaseEntity eDriver = SLogisticsDrivers.GetByID(id); return(Ok(eDriver)); }
static public bool IsLogEnabled(EBaseEntity eDriver) { //if (eDriver.driverLogMode == (int)DriverLogMode.LoggingWithGPS || eDriver.driverLogMode == (int)DriverLogMode.LoggingWithoutGPS) return true; return(false); }
public IActionResult SaveProfile([FromBody] EBaseEntity eBaseEntity) { return(Ok(SBaseEntities.SaveProfile(eBaseEntity))); }
public async Task <IActionResult> Save([FromBody] EBaseEntity eBaseEntity) { string id = await SBaseEntities.Save(eBaseEntity); return(Ok(id)); }
public IActionResult GetByID(string id) { EBaseEntity e = SCompaniesEmployees.GetByID(id); return(Ok(e)); }