/// <summary> /// Register /// </summary> /// <param name="emailAddress"></param> /// <param name="password"></param> /// <returns></returns> public int Register(string emailAddress, string password) { try { using (var e = new EntitiesModel()) { if (e.Users.Where(u => u.EmailAddress == emailAddress).Count() == 0) { var user = new User(); user.EmailAddress = emailAddress; user.Password = Crypto.EncryptStringAES(password, ; user.EmailVerified = false; user.IrcHostName = ""; user.IrcRealName = ""; user.IrcUser = ""; user.Nickname = ""; user.RegistrationGuid = ""; user.IrcServerName = ""; e.Add(user); e.SaveChanges(); return user.UserId; } else { return 0; } } } catch (Exception ex) { throw ex; } }
public void AddKategori(KategoriCreateEditViewModel model) { var kategori = new Kategori() { Nama = model.Nama }; context.Add(kategori); context.SaveChanges(); }
public void AddPembelian(PembelianCreateEditViewModel model) { var pembelian = new Pembelian() { ID = model.ID, TanggalPembelian = model.Tanggal }; context.Add(pembelian); context.SaveChanges(); }
public void AddLokasi(LokasiCreateEditViewModel model) { var lokasi = new Lokasi() { NomorRak = model.NomorRak, NomorBay = model.NomorBay }; context.Add(lokasi); context.SaveChanges(); }
public void AddDetailPembelian(PembelianDetailCreateEditViewModel model) { var pembelian = new DetilPembelian() { PembelianID = model.PembelianID, BarangID = model.BarangID }; context.Add(pembelian); context.SaveChanges(); }
public void AddBarang(BarangCreateEditViewModel model) { var barang = new Barang() { Nama = model.Nama, HargaBeli = model.HargaBeli, HargaJual = model.HargaJual, LokasiID = model.LokasiID, KategoriID = model.KategoriID }; context.Add(barang); context.SaveChanges(); }
/// <summary> /// Create /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Create(DataArrivalLogModel model) { try { using (var e = new EntitiesModel()) { var item = new DataArrivalLog(); item.Data = model.Data; item.ConnectionId = model.ConnectionId; item.Timestamp = model.Timestamp; e.Add(item); e.SaveChanges(); return(true); } } catch (Exception ex) { throw ex; } }
public void AñadirRuta(int Id, DateTime Fecha_creacion, String descripcion, Boolean estado) { using (EntitiesModel dbContext = new EntitiesModel()) { Ruta ruta = new Ruta(); ruta.Id = Id; ruta.Fecha_creacion = Fecha_creacion; ruta.Descripcion = descripcion; ruta.Estado = estado; dbContext.Add(ruta); dbContext.SaveChanges(); } }
public void AñadirProgramacion(int bus, int ruta, int empleado, DateTime fecha, String horario) { using (EntitiesModel dbContext = new EntitiesModel()) { Programacion programacion = new Programacion(); programacion.Id_bus = bus; programacion.Id_ruta = ruta; programacion.Id_empleado = empleado; programacion.Fecha = fecha; programacion.Horario = horario; dbContext.Add(programacion); dbContext.SaveChanges(); } }
private static void BulkInsert(EntitiesModel context) { List <Product> products = new List <Product>(50000); for (int i = 0; i < 30000; i++) { Product product = new Product() { ProductName = "Lexus" + i, SupplierID = 5, CategoryID = 5, UnitPrice = 1000m, QuantityPerUnit = "1 piece" }; products.Add(product); } context.Add(products); context.SaveChanges(); }
public void AñadirRecarga(Estacion estacion, Tarjetum tarjeta, DateTime fecha, DateTime hora) { using (EntitiesModel dbContext = new EntitiesModel()) { Recarga recarga = new Recarga(); recarga.Estacion = estacion ; recarga.Tarjetum = tarjeta; recarga.Fecha = fecha; recarga.Hora = hora; dbContext.Add(recarga); dbContext.SaveChanges(); } }
public void AñadirTarjeta(int id, int estacion) { using (EntitiesModel dbContext = new EntitiesModel()) { Tarjetum tarjeta = new Tarjetum(); tarjeta.Id = id; tarjeta.Saldo = 0; tarjeta.Estado = true; tarjeta.Id_estacion = estacion; dbContext.Add(tarjeta); dbContext.SaveChanges(); } }
public void AñadirConsumo(Estacion estacion, Tarjetum tarjeta, DateTime fecha, DateTime hora) { using (EntitiesModel dbContext = new EntitiesModel()) { Consumo consumo = new Consumo(); consumo.Estacion = estacion; consumo.Tarjetum = tarjeta; consumo.Fecha = fecha; consumo.Hora = hora; dbContext.Add(consumo); dbContext.SaveChanges(); } }
public void AñadirReclamo(int id,int tarjeta,int estacion, String tipo_sol, String descripcion) { using (EntitiesModel dbContext = new EntitiesModel()) { Solicitud_reclamo reclamo = new Solicitud_reclamo(); reclamo.Id_tarjeta = tarjeta; reclamo.Id_estacion = estacion; reclamo.Tipo = tipo_sol; reclamo.Descripcion = descripcion; //reclamo.Respuesta = respuesta; reclamo.Estado = "Pendiente"; reclamo.Id = id; dbContext.Add(reclamo); dbContext.SaveChanges(); } }
public void AñadirTarjetaPersonalizada(int id, int id_cliente, String numeroTel, String nombreCliente, int estacion) { using (EntitiesModel dbContext = new EntitiesModel()) { Tarjeta_personalizada tarjetaP = new Tarjeta_personalizada(); tarjetaP.Id = id; tarjetaP.Saldo = 0; tarjetaP.Estado = true; tarjetaP.Id_estacion = estacion; tarjetaP.Id_cliente = id_cliente; tarjetaP.Nombre = nombreCliente; tarjetaP.Telefono = numeroTel; dbContext.Add(tarjetaP); dbContext.SaveChanges(); } }
/// <summary> /// Create /// </summary> /// <param name="model"></param> /// <returns></returns> public int Create(ConnectionModel model) { try { using (var e = new EntitiesModel()) { var connection = new Connection(); connection.UserId = model.UserId; connection.Server = model.Server; connection.Port = model.Port; connection.Connected = model.Connected; connection.Description = model.Description; connection.Monitoring = model.Monitoring; connection.ServiceTypeId = model.ServiceTypeId; e.Add(connection); e.SaveChanges(); return(connection.ConnectionId); } } catch (Exception ex) { throw ex; } }
static void Main(string[] args) { using (EntitiesModel context = new EntitiesModel()) { context.UpdateSchema(); var head = new Header(); head.Status = HeaderStates.Created; head.Title = @"Header"; head.DateCreated = DateTime.Now; context.Add(head); head.Positions.Add(new Position { DateCreated = DateTime.Now, Description = "Position text", SequenceNumber = 1 }); context.SaveChanges(); Console.WriteLine("Positions: " + head.Positions.Count); Console.ReadKey(intercept: true); context.Delete(head); context.SaveChanges(); Console.WriteLine("Heads: " + context.Headers.Count()); Console.ReadKey(intercept: true); } }
public void AñadirBus(int Id, DateTime Fecha_adq, String modelo, String placa, String tipo, String color, String fabricante, String capacidad, String tipo_combust) { using (EntitiesModel dbContext = new EntitiesModel()) { Bu bus = new Bu(); bus.Id = Id; bus.Fecha_adq = Fecha_adq; bus.Modelo = modelo; bus.Placa = placa; bus.Tipo = tipo; bus.Color = color; bus.Fabricante = fabricante; bus.Capacidad = capacidad; bus.Tipo_combust = tipo_combust; bus.Estado = true; dbContext.Add(bus); dbContext.SaveChanges(); } }
public void AñadirEmpleado(int Id, String tipo_id, String nombre, String email, String direccion, String telefono, String cargo, String estado_civil, int salario,int esta, String clave) { using (EntitiesModel dbContext = new EntitiesModel()) { Empleado empleado = new Empleado(); empleado.Id = Id; empleado.Tipo_id = tipo_id; empleado.Nombre = nombre; empleado.Email = email; empleado.Direccion = direccion; empleado.Telefono = telefono; empleado.Cargo= cargo; //empleado.Estado_Civil = estado_civil; empleado.Salario = salario; empleado.Estado = true; empleado.Id_estacion = esta; empleado.Contrasena = clave; dbContext.Add(empleado); dbContext.SaveChanges(); } }
private void DoWork(object sender, DoWorkEventArgs e) { ProductActivation.ProductKey = ProductKey; var key = _dbContext.ActivationKeys .FirstOrDefault(a => a.ProductKey == ProductActivation.ProductKey && a.KeyStatus == 0 && a.ProductType == 0); //O represents Active and O represents PinnaFace if (key != null) { try { if (string.IsNullOrEmpty(key.BIOS_SN)) { key.BIOS_SN = ProductActivation.BiosSn; //key.FirstActivatedDate = DateTime.Now; // //GETUTCDATETIME StoredPr. //the time will be better if it is the server timer //key.ExpirationDate = key.FirstActivatedDate.Value.AddDays(key.ExpiryDuration); } else { if (!key.BIOS_SN.Contains(ProductActivation.BiosSn)) { if (key.NoOfAllowedPcs == 1) { MessageBox.Show( "Can't Activate the product, " + "Check your product key and try again, " + "or contact pinnaface office!", "More than Allowed Pcs"); ProductKey = ""; CommandsEnability = true; return; } key.BIOS_SN = key.BIOS_SN + "," + ProductActivation.BiosSn; if (key.BIOS_SN.Split(',').Count() > key.NoOfAllowedPcs) { MessageBox.Show( "Can't Activate the product, " + "Check your product key and try again, " + "or contact pinnaface office!", "More than Allowed Pcs"); ProductKey = ""; CommandsEnability = true; return; } } } key.NoOfActivations = key.NoOfActivations + 1; if (key.NoOfActivations > key.NoOfAllowedActivations) { MessageBox.Show( "Can't Activate the product, " + "Check your product key and try again, " + "or contact pinnaface office!", "More than Allowed Activations"); ProductKey = ""; CommandsEnability = true; return; } _dbContext.Add(key); _dbContext.SaveChanges(); ProductActivation.RegisteredBiosSn = key.BIOS_SN; ProductActivation.DateLastModified = DbCommandUtil.GetCurrentSqlDate(true);// DateTime.Now; //GETUTCDATETIME StoredPr ProductActivation.Synced = false; if (ProductActivation.Id == 0) { ProductActivation.LicensedTo = key.CustomerName; ProductActivation.DatabaseVersionDate = Singleton.SystemVersionDate; ProductActivation.MaximumSystemVersion = key.MaximumAllowedSystemVersion; ProductActivation.ModifiedByUserId = 1; ProductActivation.CreatedByUserId = 1; ProductActivation.DateRecordCreated = DbCommandUtil.GetCurrentSqlDate(true);//DateTime.Now; //GETUTCDATETIME StoredPr #region Set UserAccounts ProductActivation.SuperName = key.SuperName; //.Email; ProductActivation.SuperPass = key.SuperPass; ProductActivation.AdminName = key.AdminName; ProductActivation.AdminPass = key.AdminPass; ProductActivation.User1Name = key.User1Name; ProductActivation.User1Pass = key.User1Pass; #endregion #region Agency var localAgency = new AgencyDTO { AgencyName = key.CustomerName ?? (key.CustomerName = ""), AgencyNameAmharic = "-", ManagerName = "-", ManagerNameAmharic = "-", Address = new AddressDTO { AddressType = AddressTypes.Local, Country = CountryList.Ethiopia, City = EnumUtil.GetEnumDesc(CityList.AddisAbeba), Region = "14", Telephone = key.Telephone ?? (key.Telephone = ""), PrimaryEmail = key.Email ?? (key.Email = "") }, Header = new AttachmentDTO(), Footer = new AttachmentDTO(), LicenceNumber = "-", SaudiOperation = key.SaudiOperation, DubaiOperation = key.DubaiOperation, KuwaitOperation = key.KuwaitOperation, QatarOperation = key.QatarOperation, JordanOperation = key.JordanOperation, LebanonOperation = key.LebanonOperation, BahrainOperation = key.BahrainOperation, DepositAmount = "100,000 USD", Managertype = "ዋና ስራ አስኪያጅ" }; #endregion #region Foreign Agents var foreignAgent = new AgentDTO { AgentName = "-", AgentNameAmharic = "-", Address = new AddressDTO { AddressType = AddressTypes.Foreign, Country = CountryList.SaudiArabia, City = EnumUtil.GetEnumDesc(CityList.Riyadh) }, LicenseNumber = "-", Header = new AttachmentDTO(), Footer = new AttachmentDTO(), }; #endregion #region Setting var setting = new SettingDTO { AwajNumber = "923/2008", EmbassyApplicationType = EmbassyApplicationTypes.SponsorNameOnTop, SyncDuration = 1, StartSync = true, }; #endregion ProductActivation.FirstActivatedDate = key.FirstActivatedDate; // DateTime.Now; //GETUTCDATETIME StoredPr ProductActivation.ExpiryDate = key.ExpiryDate; // DateTime.Now.AddDays(key.ExpiryDuration); ProductActivation.Agency = localAgency; setting.Agency = localAgency; ////Since we don't update Header and Footer from Server we didnt need the following 6 lines //localAgency.Address.Agency = localAgency; //localAgency.Header.Agency = localAgency; //localAgency.Footer.Agency = localAgency; //foreignAgent.Address.Agency = localAgency; //foreignAgent.Header.Agency = localAgency; //foreignAgent.Footer.Agency = localAgency; _unitOfWork.Repository <AgencyDTO>().Insert(localAgency); _unitOfWork.Repository <AgentDTO>().Insert(foreignAgent); _unitOfWork.Repository <SettingDTO>().Insert(setting); _unitOfWork.Repository <ProductActivationDTO>().Insert(ProductActivation); } else { //localAgency.Synced = false; //foreignAgent.Synced = false; //_unitOfWork.Repository<AgencyDTO>().Update(localAgency); //_unitOfWork.Repository<AgentDTO>().Update(foreignAgent); _unitOfWork.Repository <ProductActivationDTO>().Update(ProductActivation); } int changes = _unitOfWork.Commit(); if (changes > 0) { Singleton.ProductActivation = ProductActivation; _login = true; } else { MessageBox.Show( "Can't Activate the product, check your product key and try again, or contact pinnasofts!"); ProductKey = ""; CommandsEnability = true; } } catch { MessageBox.Show("Error:" + Environment.NewLine + " There may be no Internet connection." + Environment.NewLine + "Check your connection and try again."); CommandsEnability = true; } } else { MessageBox.Show( "Can't Activate the product, check your product key and try again, or contact pinnasofts!"); ProductKey = ""; CommandsEnability = true; } }
private void DoWork(object sender, DoWorkEventArgs e) { ProductActivation.ProductKey = ProductKey; var act = _dbContext.ActivationKeys.FirstOrDefault(a => a.ProductKey == ProductActivation.ProductKey && a.KeyStatus == 0 && a.ProductType == 3); //O represents Active and 3 represents PinnaRent if (act != null) // { try { if (string.IsNullOrEmpty(act.BIOS_SN))//ON PinnaRent Activation Server { act.BIOS_SN = ProductActivation.BiosSn; act.FirstActivatedDate = DateTime.Now; //the time will be better if it is the server timer act.ExpirationDate = act.FirstActivatedDate.Value.AddDays(act.ExpiryDuration); } else { if (!act.BIOS_SN.Contains(ProductActivation.BiosSn)) { if (act.NoOfAllowedPcs == 1) { MessageBox.Show( "Can't Activate the product, check your product key and try again, or contact PinnaRent office!"); ProductKey = ""; CommandsEnability = true; return; } act.BIOS_SN = act.BIOS_SN + "," + ProductActivation.BiosSn; if (act.BIOS_SN.Split(',').Count() > act.NoOfAllowedPcs) { MessageBox.Show( "Can't Activate the product, check your product key and try again, or contact PinnaRent office!"); ProductKey = ""; CommandsEnability = true; return; } } } act.NoOfActivations = act.NoOfActivations + 1; _dbContext.Add(act); _dbContext.SaveChanges(); ProductActivation.RegisteredBiosSn = act.BIOS_SN; if (ProductActivation.Id == 0) { ProductActivation.LicensedTo = act.CustomerName; ProductActivation.DateLastModified = DateTime.Now; ProductActivation.ModifiedByUserId = 1; ProductActivation.CreatedByUserId = 1; ProductActivation.DateRecordCreated = DateTime.Now; ProductActivation.ActivatedDate = DateTime.Now; ProductActivation.ExpirationDate = DateTime.Now.AddDays(act.ExpiryDuration); if (Singleton.Edition != PinnaRentEdition.OnlineEdition) { #region Company var company = new CompanyDTO { DisplayName = act.CustomerName, CompanyAddress = new AddressDTO { Country = "ኢትዮጲያ", City = "አዲስ አበባ", Telephone = act.Telephone, PrimaryEmail = act.Email }, Address = new AddressDTO { Country = "ኢትዮጲያ", City = "አዲስ አበባ", Telephone = act.Telephone, PrimaryEmail = act.Email } }; #endregion #region Warehouse var warehouse = new WarehouseDTO { Id = 1, DisplayName = "_Default Store", WarehouseNumber = 11, IsDefault = true, Company = company, Address = new AddressDTO { Country = "Ethiopia", City = "Addis Abeba" } }; #endregion _unitOfWork.Repository <CompanyDTO>().Insert(company); _unitOfWork.Repository <WarehouseDTO>().Insert(warehouse); } _unitOfWork.Repository <ProductActivationDTO>().Insert(ProductActivation); } else { _unitOfWork.Repository <ProductActivationDTO>().Update(ProductActivation); } _unitOfWork.Commit(); Singleton.ProductActivation = ProductActivation; _login = true; } catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + " There may be no Internet connection." + Environment.NewLine + "Check your connection and try again." + Environment.NewLine + ex.Message); CommandsEnability = true; } } else { MessageBox.Show("Can't Activate the product, check your product key and try again, or contact PinnaRent office!"); ProductKey = ""; CommandsEnability = true; } }
private void DoWork(object sender, DoWorkEventArgs e) { ProductActivation.ProductKey = ProductKey; var act = _dbContext.ActivationKeys.FirstOrDefault(a => a.ProductKey == ProductActivation.ProductKey && a.KeyStatus == 0 && a.ProductType == 2);//O represents Active and 1 represents PinnaFit,2=PinnaFit if (act != null) { try { if (string.IsNullOrEmpty(act.BIOS_SN))//ON PinnaFit Activation Server { act.BIOS_SN = ProductActivation.BiosSn; act.FirstActivatedDate = DateTime.Now; //the time will be better if it is the server timer act.ExpirationDate = act.FirstActivatedDate.Value.AddDays(act.ExpiryDuration); } else { if (!act.BIOS_SN.Contains(ProductActivation.BiosSn)) { if (act.NoOfAllowedPcs == 1) { MessageBox.Show( "Can't Activate the product, check your product key and try again, or contact PinnaFit office!"); ProductKey = ""; CommandsEnability = true; return; } act.BIOS_SN = act.BIOS_SN + "," + ProductActivation.BiosSn; if (act.BIOS_SN.Split(',').Count() > act.NoOfAllowedPcs) { MessageBox.Show( "Can't Activate the product, check your product key and try again, or contact PinnaFit office!"); ProductKey = ""; CommandsEnability = true; return; } } } act.NoOfActivations = act.NoOfActivations + 1; _dbContext.Add(act); _dbContext.SaveChanges(); ProductActivation.RegisteredBiosSn = act.BIOS_SN; if (ProductActivation.Id == 0) { ProductActivation.LicensedTo = act.CustomerName; ProductActivation.DateLastModified = DateTime.Now; ProductActivation.ModifiedByUserId = 1; ProductActivation.CreatedByUserId = 1; ProductActivation.DateRecordCreated = DateTime.Now; ProductActivation.ActivatedDate = DateTime.Now; ProductActivation.ExpirationDate = DateTime.Now.AddDays(act.ExpiryDuration); if (Singleton.Edition != PinnaFitEdition.OnlineEdition) { #region Company var company = new CompanyDTO { Id = 1, DisplayName = "Deyinsher Fitness Center", Address = new AddressDTO { AddressDetail = "Jemmo, Yehender Business Center, Ground Floor", Country = "ኢትዮጲያ", City = "አዲስ አበባ", Telephone = "0111266701", Mobile = "0929142121", AlternateMobile = "0911168312", PrimaryEmail = "*****@*****.**" } }; #endregion _unitOfWork.Repository <CompanyDTO>().Insert(company); } _unitOfWork.Repository <ProductActivationDTO>().Insert(ProductActivation); } else { _unitOfWork.Repository <ProductActivationDTO>().Update(ProductActivation); } _unitOfWork.Commit(); Singleton.ProductActivation = ProductActivation; //new Login().Show(); _login = true; } catch (Exception ex) { MessageBox.Show("Error:" + Environment.NewLine + " There may be no Internet connection." + Environment.NewLine + "Check your connection and try again." + Environment.NewLine + ex.Message); CommandsEnability = true; } } else { MessageBox.Show("Can't Activate the product, check your product key and try again, or contact PinnaFit office!"); ProductKey = ""; CommandsEnability = true; } }