public VinaGerman.Entity.BusinessEntity.ContactEntity AddOrUpdateContact(VinaGerman.Entity.BusinessEntity.ContactEntity entityObject) { string sqlStatement = ""; //if insert if (entityObject.ContactId > 0) { sqlStatement += "UPDATE Contact SET " + Environment.NewLine + "FullName=@FullName," + Environment.NewLine + "Email=@Email," + Environment.NewLine + "Phone=@Phone," + Environment.NewLine + "Address=@Address," + Environment.NewLine + "CompanyId=@CompanyId," + Environment.NewLine + "UserAccountId=@UserAccountId," + Environment.NewLine + "Position=@Position," + Environment.NewLine + "DepartmentId=@DepartmentId," + Environment.NewLine + "Deleted=@Deleted" + Environment.NewLine + "WHERE ContactId=@ContactId " + Environment.NewLine + "SELECT @ContactId AS ContactId " + Environment.NewLine; } else { sqlStatement += "INSERT INTO Contact( " + Environment.NewLine + "FullName," + Environment.NewLine + "Email," + Environment.NewLine + "Phone," + Environment.NewLine + "Address," + Environment.NewLine + "CompanyId," + Environment.NewLine + "UserAccountId," + Environment.NewLine + "Position," + Environment.NewLine + "DepartmentId," + Environment.NewLine + "Deleted)" + Environment.NewLine + "VALUES (" + Environment.NewLine + "@FullName," + Environment.NewLine + "@Email," + Environment.NewLine + "@Phone," + Environment.NewLine + "@Address," + Environment.NewLine + "@CompanyId," + Environment.NewLine + "@UserAccountId," + Environment.NewLine + "@Position," + Environment.NewLine + "@DepartmentId," + Environment.NewLine + "@Deleted)" + Environment.NewLine + "SELECT SCOPE_IDENTITY() AS ContactId" + Environment.NewLine; } //execute entityObject.ContactId = Connection.ExecuteScalar<int>(sqlStatement, new { ContactId = entityObject.ContactId, FullName = entityObject.FullName, Email = entityObject.Email, Phone = entityObject.Phone, Address = entityObject.Address, CompanyId = entityObject.CompanyId, UserAccountId = entityObject.UserAccountId, Position = entityObject.Position, DepartmentId = entityObject.DepartmentId, Deleted = (entityObject.Deleted ? 1 : 0) }, Transaction); return entityObject; }
public bool DeleteContact(VinaGerman.Entity.BusinessEntity.ContactEntity entityObject) { string sqlStatement = "UPDATE Contact SET Deleted=1 WHERE ContactId=@ContactId " + Environment.NewLine; //execute Connection.Execute(sqlStatement, new { ContactId = entityObject.ContactId }, Transaction); return true; }
public bool DeleteContact(VinaGerman.Entity.BusinessEntity.ContactEntity entityObject) { //execute using (var db = VinaGerman.Database.VinagermanDatabase.GetDatabaseInstance()) { try { db.OpenConnection(); return db.Resolve<IContactDB>().DeleteContact(entityObject); } finally { db.CloseConnection(); } } }
public void Save(VinaGerman.Entity.BusinessEntity.ContactEntity entityObject) { System.Threading.ThreadPool.QueueUserWorkItem(delegate { try { ShowLoading(StringResources.captionInformation, StringResources.msgLoading); var updatedEntity = Factory.Resolve<IBaseDataDS>().AddOrUpdateContact(entityObject); HideLoading(); //display to UI Application.Current.Dispatcher.Invoke(new Action(() => { AddOrUpdateContact(updatedEntity); })); } catch (Exception ex) { HideLoading(); ShowMessageBox(StringResources.captionError, ex.ToString(), MessageBoxButton.OK); } }); }
public void AddOrUpdateContact(VinaGerman.Entity.BusinessEntity.ContactEntity newEntity) { VinaGerman.Entity.BusinessEntity.ContactEntity oldEntity = ContactList.FirstOrDefault<VinaGerman.Entity.BusinessEntity.ContactEntity>(p => p.FullName == newEntity.FullName); if (oldEntity == null) { ContactList.Insert(0, newEntity); } else { int index = ContactList.IndexOf(oldEntity); ContactList.Remove(oldEntity); ContactList.Insert(index, newEntity); } ContactList = new List<VinaGerman.Entity.BusinessEntity.ContactEntity>(_contactList); }
public void DeleteContact(VinaGerman.Entity.BusinessEntity.ContactEntity newEntity) { VinaGerman.Entity.BusinessEntity.ContactEntity oldEntity = ContactList.FirstOrDefault<VinaGerman.Entity.BusinessEntity.ContactEntity>(p => p.ContactId == newEntity.ContactId); if (oldEntity != null) { ContactList.Remove(oldEntity); } ContactList = new List<VinaGerman.Entity.BusinessEntity.ContactEntity>(_contactList); }
public void Delete(VinaGerman.Entity.BusinessEntity.LocationEntity entityObject) { if (ShowMessageBox(StringResources.captionConfirm, StringResources.msgConfirmDelete, MessageBoxButton.YesNo) == MessageBoxResult.Yes) { System.Threading.ThreadPool.QueueUserWorkItem(delegate { try { ShowLoading(StringResources.captionInformation, StringResources.msgLoading); var updatedEntity = Factory.Resolve<ICompanyDS>().DeleteLocation(entityObject); HideLoading(); //display to UI Application.Current.Dispatcher.Invoke(new Action(() => { DeleteLocation(entityObject); })); } catch (Exception ex) { HideLoading(); ShowMessageBox(StringResources.captionError, ex.ToString(), MessageBoxButton.OK); } }); } }
public void DeleteLocation(VinaGerman.Entity.BusinessEntity.LocationEntity newEntity) { VinaGerman.Entity.BusinessEntity.LocationEntity oldEntity = LocationList.FirstOrDefault<VinaGerman.Entity.BusinessEntity.LocationEntity>(p => p.LocationId == newEntity.LocationId); if (oldEntity != null) { LocationList.Remove(oldEntity); } LocationList = new List<VinaGerman.Entity.BusinessEntity.LocationEntity>(_locationList); }
public bool DeleteLocation(VinaGerman.Entity.BusinessEntity.LocationEntity entityObject) { return Factory.Resolve<ILocationBL>().DeleteLocation(entityObject); }
public void AddOrUpdateLocation(VinaGerman.Entity.BusinessEntity.LocationEntity newEntity) { VinaGerman.Entity.BusinessEntity.LocationEntity oldEntity = LocationList.FirstOrDefault<VinaGerman.Entity.BusinessEntity.LocationEntity>(p => p.Description == newEntity.Description); if (oldEntity == null) { LocationList.Insert(0, newEntity); } else { int index = LocationList.IndexOf(oldEntity); LocationList.Remove(oldEntity); LocationList.Insert(index, newEntity); } LocationList = new List<VinaGerman.Entity.BusinessEntity.LocationEntity>(_locationList); }
public bool DeleteDepartment(VinaGerman.Entity.BusinessEntity.DepartmentEntity entityObject) { return Factory.Resolve<IDepartmentBL>().DeleteDepartment(entityObject); }
public bool DeleteContact(VinaGerman.Entity.BusinessEntity.ContactEntity entityObject) { return Factory.Resolve<IContactBL>().DeleteContact(entityObject); }
public VinaGerman.Entity.BusinessEntity.LocationEntity AddOrUpdateLocation(VinaGerman.Entity.BusinessEntity.LocationEntity entityObject) { return Factory.Resolve<ILocationBL>().AddOrUpdateLocation(entityObject); }
public VinaGerman.Entity.BusinessEntity.DepartmentEntity AddOrUpdateDepartment(VinaGerman.Entity.BusinessEntity.DepartmentEntity entityObject) { return Factory.Resolve<IDepartmentBL>().AddOrUpdateDepartment(entityObject); }
public VinaGerman.Entity.BusinessEntity.ContactEntity AddOrUpdateContact(VinaGerman.Entity.BusinessEntity.ContactEntity entityObject) { return Factory.Resolve<IContactBL>().AddOrUpdateContact(entityObject); }