public void AddNewUser(FraudModel user) { var fraudUser = new FraudUser { FirstName = user.FirstName, LastName = user.LastName }; // ReSharper disable ReturnValueOfPureMethodIsNotUsed user.Addresses.Select(x => { x.FraudUser = fraudUser; return(x); }).ToList(); user.Phones.Select(x => { x.FraudUser = fraudUser; return(x); }).ToList(); user.Emails.Select(x => { x.FraudUser = fraudUser; return(x); }).ToList(); user.Companies.Select(x => { x.FraudUser = fraudUser; return(x); }).ToList(); user.BankAccounts.Select(x => { x.FraudUser = fraudUser; return(x); }).ToList(); user.EmailDomains.Select(x => { x.FraudUser = fraudUser; return(x); }).ToList(); // ReSharper restore ReturnValueOfPureMethodIsNotUsed fraudUser.Addresses.AddAll(user.Addresses); fraudUser.Phones.AddAll(user.Phones); fraudUser.Emails.AddAll(user.Emails); fraudUser.Companies.AddAll(user.Companies); fraudUser.BankAccounts.AddAll(user.BankAccounts); fraudUser.EmailDomains.AddAll(user.EmailDomains); fraudUser.Shops.AddAll( user.Shops.Select(x => new FraudShop { Name = x.Name, Type = _mpType.GetAll().First(y => y.Name == x.Type), FraudUser = fraudUser }).ToList() ); _fraudUserRepository.Save(fraudUser); }
public List <FraudModel> Fraud(string code, DateTime from, DateTime to) { var result = new List <FraudModel>(); // old table: grafica_serie_fraude using (var connection = new NpgsqlConnection(_connectionString)) { var command = new NpgsqlCommand( @"select fecha, energia_g03, sum_energia_imp_salidas from grafica_serie_fraude_bcg where matricula = @Code and fecha >= @From and fecha <= @To order by fecha", connection); command.Parameters.Add("Code", NpgsqlDbType.Varchar).Value = code; command.Parameters.Add("From", NpgsqlDbType.Timestamp).Value = from; command.Parameters.Add("To", NpgsqlDbType.Timestamp).Value = to; connection.Open(); var reader = command.ExecuteReader(); while (reader.Read()) { if (reader.IsDBNull(1) || reader.IsDBNull(2)) { continue; } var model = new FraudModel { Date = (DateTime)reader["fecha"], Ct = (long)reader["energia_g03"], Exit = (double)reader["sum_energia_imp_salidas"] }; result.Add(model); } reader.Close(); } return(result); }
public JsonResult GetAll() { var model = FraudModel.FromFraudModel(_fraudUserRepository.GetAll().OrderByDescending(x => x.Id).ToList()); return(Json(model, JsonRequestBehavior.AllowGet)); }