private static void AddSearchPieceInDB(string piece) { using (DbModelContext dbContext = new DbModelContext()) { IstoricCautari tempHistory = new IstoricCautari { Id_Cautare = StringToGUID(piece), Valoare = piece.Trim(), Cod = piece.Trim().GetHashCode().ToString() }; dbContext.IstoricCautari.Add(tempHistory); dbContext.SaveChanges(); } }
internal static void RemoveProductAlert(Guid userId, Guid productId) { try { using (var dbContext = new DbModelContext()) { var item = dbContext.UrmarireProdus.Where(m => m.Id_Produs.Equals(productId) && m.Id_Utilizator.Equals(userId)).FirstOrDefault(); item.Invalid = true; dbContext.SaveChanges(); } } catch (Exception ex) { } }
private static void InsertCompleteIdiomInDatabase(string stringToSearch, string searchIdiomCode) { using (DbModelContext dbContext = new DbModelContext()) { try { IstoricCautari history = new IstoricCautari() { Cod = searchIdiomCode, Valoare = stringToSearch, Id_Cautare = StringToGUID(stringToSearch) }; dbContext.IstoricCautari.Add(history); dbContext.SaveChanges(); } catch { } } }
internal static void AddUserToDb(UserModel user) { using (var dbContext = new DbModelContext()) { var crypto = new SimpleCrypto.PBKDF2(); var encPass = crypto.Compute(user.Parola); var tempUser = dbContext.Utilizator.Create(); tempUser.Id = Guid.NewGuid(); tempUser.Numar_Telefon = user.Numar_Telefon; tempUser.Nume_Utilizator = user.Nume_Utilizator; tempUser.Parola = encPass; tempUser.Porecla = user.Porecla; tempUser.Rol = "0"; tempUser.Email = user.Email; tempUser.CheieParola = crypto.Salt; dbContext.Utilizator.Add(tempUser); dbContext.SaveChanges(); } }
internal static void AddProductAllert(Guid producId, Guid UserId, string price) { using (var dbContext = new DbModelContext()) { try { UrmarireProdus tempAlert = new UrmarireProdus(); tempAlert.Id = Guid.NewGuid(); tempAlert.Id_Produs = producId; tempAlert.Id_Utilizator = UserId; tempAlert.Limita_pret = decimal.Parse(price); tempAlert.Invalid = false; tempAlert.UtilizatorNotificat = false; tempAlert.DataNotificarii = DateTime.UtcNow; dbContext.UrmarireProdus.Add(tempAlert); dbContext.SaveChanges(); } catch (Exception ex) { } } }