public bool DeleteLocation(LocationEntity entityObject) { string sqlStatement = "UPDATE Location SET Deleted=1 WHERE LocationId=@LocationId " + Environment.NewLine; //execute Connection.Execute(sqlStatement, new { LocationId = entityObject.LocationId }, Transaction); return true; }
public bool DeleteLocation(LocationEntity entityObject) { //execute using (var db = VinaGerman.Database.VinagermanDatabase.GetDatabaseInstance()) { try { db.OpenConnection(); return db.Resolve<ILocationDB>().DeleteLocation(entityObject); } finally { db.CloseConnection(); } } }
public LocationEntity AddOrUpdateLocation(LocationEntity entityObject) { string sqlStatement = ""; //if insert if (entityObject.LocationId > 0) { sqlStatement += "UPDATE Location SET " + Environment.NewLine + "Address=@Address," + Environment.NewLine + "Description=@Description," + Environment.NewLine + "CompanyId=@CompanyId," + Environment.NewLine + "Deleted=@Deleted" + Environment.NewLine + "WHERE LocationId=@LocationId " + Environment.NewLine + "SELECT @LocationId AS LocationId " + Environment.NewLine; } else { sqlStatement += "INSERT INTO Location( " + Environment.NewLine + "Address," + Environment.NewLine + "Description," + Environment.NewLine + "CompanyId," + Environment.NewLine + "Deleted)" + Environment.NewLine + "VALUES (" + Environment.NewLine + "@Address," + Environment.NewLine + "@Description," + Environment.NewLine + "@CompanyId," + Environment.NewLine + "@Deleted)" + Environment.NewLine + "SELECT SCOPE_IDENTITY() AS LocationId" + Environment.NewLine; } //execute entityObject.LocationId = Connection.ExecuteScalar<int>(sqlStatement, new { LocationId = entityObject.LocationId, Phone = entityObject.Address, Description = entityObject.Description, CompanyId = entityObject.CompanyId, Address = entityObject.Address, Deleted = (entityObject.Deleted ? 1 : 0) }, Transaction); return entityObject; }